HELP PLEASE : how do I use the return function?
can someone please help me out. How do i return it back to " A = int(input("Please Enter A Numerical Length For the Triangle: A = "))" . I have no clues on how to do it. Could some expert help me out please!!
I did it using the strip of code.
name = input("What is your name? \n") #asking the user their name
print("Welcome, " + name + "!") #print the message with customer name
print("Let plays the triangle guesing game") #welcome messages
is_number = False
while is_number == False:
A = input("Please Enter A Numerical Length For the Triangle: A = ")
for i in A:
if i in ["0","1","2","3","4","5","6","7","8","9"]:
is_number = True
else: print("That is not an Numerical, Please ONLY ENTER NUMERICAL") break
I kept the input in a loop and checked if it was an int in the loop if so then it breaks the loop.
for example: when the user enter a number than it is ok, but when they enter "non-numerical" input such as abc or [email protected]#. It will tell themto "That is not an Numerical, Please ONLY ENTER NUMERICAL". My question is after the message "That is not an Numerical, Please ONLY ENTER NUMERICAL" how do I make it to return back to "Please Enter A Numerical Length For the Triangle: A =" without run the program again. Thank you in advance for helping me out
You could use a while True loop in front of the try except clause, then add a break in the try part.