About 4,190,000 results
Open links in new tab
  1. python - How do you check to see if an input is equal to a …

    May 26, 2015 · I know how to check if an input is an integer but not a specific integer. For example for my code I want to check if the input is equal to 1, 2 or 3 and then ask the user to …

  2. Input Validation in Python - GeeksforGeeks

    Apr 18, 2025 · Python provides several ways to validate user inputs, let's explore some. One of the simplest methods to ensure the input is of the correct type is to use a try-except block. For …

  3. python - How to evaluate if a variable is equal to user input

    Sep 12, 2011 · names=['Scott', 'Doug', 'Sam', 'Harry'] typedname=str(input('What is your name?: ')) if typedname==['Scott' or 'Doug' or 'Sam' or 'Harry']: print('you are '+typedname) else: …

  4. python - Check if an input is equal to any item in the list - Stack ...

    Nov 22, 2018 · let's say we have a list a=["a1", "a2", "a3"] then we have an input: x=input("enter something: ") how would you check if that input "x" is equal to any item in the list and then …

  5. How do i make Python say: If user input equals Y or N(yes or ... - Reddit

    Dec 8, 2019 · How do i make Python say: If user input equals Y or N (yes or no), then do something? You're almost there. You need to assign your input to your variable. question = …

  6. How to Validate user input in Python - bobbyhadz

    Apr 9, 2024 · To validate user input: Use a while loop to iterate until the provided input value is valid. Check if the input value is valid on each iteration. If the value is valid, break out of the …

  7. Yes/No question with user input in Python - bobbyhadz

    We used the input() function to take input from the user. The if statement checks if the user entered yes and prints a message. We used the str.lower() method to convert the user input …

  8. Testing for Equality - Cave of Python

    Often we want to check if two things are equal to each other. We can do this with the equality test operator, == Note that we do not use single ‘=’ to test if two things are equal; the single equals …

  9. How to compare inputs in Python - kodeclik.com

    The operator to compare inputs in Python changes depending on the data types you are comparing. Use ==, <, >, or define your own __eq__() method in your class.

  10. How do I check an input answer in python 3 - Stack Overflow

    answer = "" while answer != "yes" and answer != "no":answer = input("Do you want to go left or right?[Valid answer is yes/no\n").lower() if answer == "yes" : print("You start to walk left") else: …