Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

repeating a program in python

#Alan's Toolkit for conversions

invalid_input = True
def start() :
    print ("Welcome to the converter toolkit made by Alan.")
    op = input ("Please input what operation you wish to perform. 1 for Fahrenheit to Celsius, 2 for meters to centimetres and 3 for megabytes to gigabytes")
    if op == "1":
        #stuff
        invalid_input = False # Set to False because input was valid


    elif op == "2":
        #stuff
        invalid_input = False # Set to False because input was valid
    elif op == "3": # you still have this as "if"; I would recommend keeping it as elif
        #stuff
        invalid_input = False # Set to False because input was valid
    else:
        print ("Sorry, that was an invalid command!")

while invalid_input: # this will loop until invalid_input is set to be False
    start()
Comment

PREVIOUS NEXT
Code Example
Python :: pytghon 
Python :: can we use for loop inside if statement 
Python :: pie plot chance size python 
Python :: no repetir elementos en una lista python 
Python :: Errors that you will get in the Time class in Python DateTime 
Python :: How to provide type hinting in UserDict 
Python :: create new column with first character of string pyspark 
Python :: NxN Array 
Python :: python dateien auflisten 
Python :: for loop python terminal 
Python :: binning continuous values in pyspark 
Python :: python ternary mittels ganz schlimm 
Python :: python get combobox value 
Python :: how to open local software using python 
Python :: Passive to active Python 
Python :: sample stochastic gradient boosting regressor algorithm 
Python :: print command in python 
Python :: calculate sin cos tan python 
Python :: get value of list separately python 
Python :: scaling, cross validation and fitting a model through a pipline 
Python :: Drop multiple consecutive columns 
Python :: How to Use the abs() Function with an Integer Argument 
Python :: python tkinter button multiple commands 
Python :: python pid control 
Python :: studygyaan python everywhere - host on heroku 
Python :: addDataToExp() psychopy 
Python :: funzione generatore python 
Python :: aggregation with f() in django rest api 
Python :: micropython string to int 
Python :: newspaper pypi 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =