May-26-2020, 08:51 AM
The way you use except is wrong - The except block lets you handle the error. So for example
here, even if the input is greater than 1, an error will not come.
You will have to use a while loop like
try: print(x) except NameError: print("Variable x is not defined") except: print("Something else went wrong")Here, the variable x is not defined, and therefore, a Nameerror will come like
Error:Variable x not defined
like thathere, even if the input is greater than 1, an error will not come.
You will have to use a while loop like
while Score > 1: Score = input('enter number between 0 and 1\n')Then print your rest of the code. The while loop will work as long as your score is greater than 1. When it becomes less than 1, it will automatically break
pyzyx3qwerty
"The greatest glory in living lies not in never falling, but in rising every time we fall." - Nelson Mandela
Need help on the forum? Visit help @ python forum
For learning more and more about python, visit Python docs
"The greatest glory in living lies not in never falling, but in rising every time we fall." - Nelson Mandela
Need help on the forum? Visit help @ python forum
For learning more and more about python, visit Python docs