-2
val = [*range(1,51)]

print("Now, I need aaato know how many state Capitals you would like to practice")
user = input("chose a number from 1 to 50")
while user not in val:
    print("There are 50 States in the United States. You need to pick a number between 1-50. If you want to exit the game, type \"EXIT\"")
    user = input("I needbbb to know how many state Capitals you would like to practice")
    if user.capitalize() == "EXIT":
        break
    if user == 0:
        print("There are more than zero States in the United Sts That means that you do not want to play today")
        user = input("I needccc to know how many state Capitals you would like to practice. If you want to exit the game, type \"EXIT\"")

print("Hello")

output:

There are 50 States in the United States. You need to pick a number between 1-50. If you want to exit the game, type "EXIT" I needbbb to know how many state Capitals you would like to practice0 There are 50 States in the United States. You need to pick a number between 1-50. If you want to exit the game, type "EXIT" I needbbb to know how many state Capitals you would like to practice5 There are 50 States in the United States. You need to pick a number between 1-50. If you want to exit the game, type "EXIT" I needbbb to know how many state Capitals you would like to practice123 There are 50 States in the United States. You need to pick a number between 1-50. If you want to exit the game, type "EXIT" I needbbb to know how many state Capitals you would like to practice5 There are 50 States in the United States. You need to pick a number between 1-50. If you want to exit the game, type "EXIT" I needbbb to know how many state Capitals you would like to practice0 There are 50 States in the United States. You need to pick a number between 1-50. If you want to exit the game, type "EXIT" I needbbb to know how many state Capitals you would like to practiceexit There are 50 States in the United States. You need to pick a number between 1-50. If you want to exit the game, type "EXIT" I needbbb to know how many state Capitals you would like to practice

I created a list with ints between the number 1 and 50. I want the user to pick a number from the list (val). If it's not there, I want the user to keep trying. Unless the user wants to quit with "EXIT".

It just keeps getting stuck in my user input print statement and I dont understand why?

rgw
  • 1
  • 1

1 Answers1

0

You want user.upper(), not user.capitalize().

From the help-text:

>>> help(str.capitalize)
Help on method_descriptor:

capitalize(self, /)
    Return a capitalized version of the string.

    More specifically, make the first character have upper case and the rest lower
    case.

>>> help(str.upper)
Help on method_descriptor:

upper(self, /)
    Return a copy of the string converted to uppercase.
scotscotmcc
  • 2,719
  • 1
  • 6
  • 29