Solution:
answer = input("Return TRUE or FALSE: Python was released in 1991:\n") if answer == "TRUE": print('Correct') elif answer == "FALSE": print('Wrong') elif answer != ("TRUE" or "FALSE"): print('Please answer TRUE or FALSE') print('Bye!')
Solution:
Define the password and the Boolean validator first:
user_pass = "random" valid = False
Initiate the while loop and ask for the user's input:
while not valid: password = input("please enter your password: ")
Validate the password and return an error if the input is invalid:
if password == user_pass: print("Welcome back user!") valid = True else: print("invalid password, try again... ")
Your block of code should look as follows; take note of the indentation:
user_pass = "random" valid = False while not valid: password = input("please enter your password: ") if password == user_pass: print("Welcome back user!") valid = True else: print("invalid password, try again... ")
Solution:
>>> total = 0 >>> for number in range(2,101,2): total += number >>> print(total)
Solution:
for even in range(2,11,2): for odd in range(1,11,2): val = even + odd print(even, "+", odd, "=", val)