dimanche 25 novembre 2018

using an if statement with a greater than of less statement so only numbers between 0 and 100 are added to my list

I and trying to make it so only the numbers in between 0 and 100 are added to my list I feel like i have the syntax correct but for some reason the only input being added is 10 anything besides that spits out my else statement. I know my code could probably be cleaned up but I am really just trying to figure out the greater than or less than issue because everything else works.

 elif selection == '2':
    score = input("Please enter a score between 0 and 100: ")

    if '0'<= score <= '100':
        try:
            score =float(score)
            base.append(score)
        except ValueError:
            print("Invalid Input.")
            print("{} is not a valid input.".format(score))
        else:
            print(menu)
            selection = input("Please enter selection: ")

    else:
      print("{} is not within selected range.".format(score))
      print()
      print(menu)
      selection = input("Please enter selection: ")

Aucun commentaire:

Enregistrer un commentaire