Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to repeat if statement in python

def main():
    while True:
        again = raw_input("Would you like to play again? Enter y/n: ")

        if again == "n":
            print ("Thanks for Playing!")
            return
        elif again == "y":
            print ("Lets play again..")
        else:
            print ("You should enter either "y" or "n".")

if __name__ == "__main__":
    main()
Comment

PREVIOUS NEXT
Code Example
Python :: python module install a whl 
Python :: __delattr__ python 
Python :: numpy random for string 
Python :: how to enter a int in python 
Python :: represent NaN with pandas in python 
Python :: gogle query python simple 
Python :: numpy copy array 
Python :: pandas drop missing values for any column 
Python :: how to add in python 
Python :: normalize numpy array 
Python :: insert row in any position pandas dataframe 
Python :: pandas df to dict 
Python :: math domain error python 
Python :: sharpdevelop pause python code 
Python :: insert column in a dataframe 
Python :: python int16 
Python :: python logging to syslog linux 
Python :: python string trim 
Python :: python get array length 
Python :: how to sort the dataframe in python by axis 
Python :: lastindexof python 
Python :: read data from excel and plot in python 
Python :: bounding box python 
Python :: get basename without extension python 
Python :: pandas read to a csv file 
Python :: itertools .cycle() 
Python :: pillow python text example 
Python :: readlines replace  
Python :: split stringg to columns python 
Python :: addition of matrix in python using numpy 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =