#(a) Write a program that keeps asking the user for their name until they enter "Tim". Otherwise, keep saying "You are not Tim!" and ask for their name.
#(b) Allow your name as a valid input as well.
#(c) Keep track of how many times the user fails to enter the correct name, and report it when they finally get it right. (2K, 2C)
name = input('Enter your name: ') #ask user to input name
count = 0 #initialize counter of fails
#keep asking while Tim or YourName (replace it with your real name) are entered
while (name != 'Tim') and (name != 'YourName'):
print("You are not Tim!") #print warning
name = input('Enter your name: ') #ask for input
count += 1 #increment number of fails
print("You failed {} times".format(count))
Comments
Leave a comment