Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to give multiple option to the user and ask the same question again and again until the user tells one of the options

while True:
    data = input("Please enter a loud message (must be all caps): ")
    if not data.isupper():
        print("Sorry, your response was not loud enough.")
        continue
    else:
        #we're happy with the value given.
        #we're ready to exit the loop.
        break

while True:
    data = input("Pick an answer from A to D:")
    if data.lower() not in ('a', 'b', 'c', 'd'):
        print("Not an appropriate choice.")
    else:
        break
Comment

PREVIOUS NEXT
Code Example
Python :: what is the tracing output of the code below x=10 y=50 if(x**2 100 and y <100): print(x,y) 
Python :: how to pronounce aesthetic 
Python :: python os is directory 
Python :: how to install django in virtual environment in ubuntu 
Python :: user input dictionary python 
Python :: datetime current year 
Python :: python get script path 
Python :: pandas add a column with loc 
Python :: how to get started with python 
Python :: restart computer py 
Python :: removing odd index character of a given string in python 
Python :: pandas sample seed 
Python :: OneID flask 
Python :: django admin order by 
Python :: pandas normalize groupby 
Python :: how to factorise expressions in python 
Python :: check cuda available tensorflow 
Python :: how to end the python program 
Python :: print undeline and bold text in python 
Python :: how to change dtype object to int 
Python :: waitkey in opencv 
Python :: get time between things python 
Python :: how to get chat first name in telebot 
Python :: remove newlines from csv 
Python :: managing media in django 
Python :: jinja len is undefined 
Python :: saving to csv without the index 
Python :: filter rows pandas 
Python :: pandas groupby aggregate quantile 
Python :: `distplot` is a deprecated function and will be removed in a future version 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =