tries = 3 while tries > 0: guess=input("guess my name") tries = tries -1 print("game over!")
guess my name> Aaron
guess my name> Ali
guess my name> Adam
game over!
seconds = 3 while seconds > 0: print(f"{seconds} seconds left.") seconds = seconds - 1 print("Times's up!")
3
2
1
Time's up!
word, index = "", 4 myList = ["c","o","d","e","f","e","z"] while index < len(myList): word = word + myList[index] index +=1 print(word)
fez
password, attempts = "secret", 3 while attempts > 0: guess = input("Enter the password") attempts -= 1 if guess == password: print("Access granted!") break
Enter the password> password123
Enter the password> letmein
Enter the password> password
fruits = ["apple", "banana", "orange"] index = 1 while index < len(fruits): print(fruits[index]) index += 1
banana
orange
word, index = "", 4 myList = ["c","o","d","e","f","e","z"] while index < len(myList): word = word + myList[index] print(myList[index]) index +=1
f
e
z
myList = ["code", "fez"] password = input("enter your access key") while password not in myList: password = input("no such access key. Try again") print("access granted")
enter your access key> password123
no such access key. Try again> codefez
no such access key. Try again> fez
access granted