[Solved] This python code calls a function that returns a value but user input is asked twice [closed]


Within the function grades you’re asking for the score:

score = float(input("enter the score please"))

and then outside of the function, you’re also doing it:

MyScore=float(input("enter my score"))

Remove one of the two input statements, and it will only ask you the one time 🙂

def grades(score):

 if score<0.0 or score>1.0:
      return "Wrong score"
 elif score==0.9:
      return "A"
 elif score==0.8:
      return "B"
 elif score==0.7:
      return "C"
 elif score==0.6:
      return "D"
 elif score==0.5:
      return "B"
 else :
      return "F"


try:
        score = float(input("enter the score please"))
except:
        score = -1

result=grades(score)
print(result)'

3

solved This python code calls a function that returns a value but user input is asked twice [closed]