Complete the code to create an infinite loop using while.
while [1]: print("Looping forever")
The while True statement creates an infinite loop because the condition is always true.
Complete the code to break out of the infinite loop when user types 'exit'.
while True: user_input = input("Type something: ") if user_input == [1]: break
The loop breaks when the user types exit, so the condition must check for the string "exit".
Fix the error in the loop condition to make it an infinite loop.
while [1] == True: print("Running")
The condition must be True to run infinitely. Using True == True is valid but redundant; just while True: is preferred.
Fill both blanks to create a loop that asks for a number and stops when the number is 0.
while [1]: num = int(input("Enter number: ")) if num [2] 0: break
while False which never runs the loop.!= which breaks on wrong condition.The loop runs infinitely with while True: and breaks when num == 0.
Fill all three blanks to create a loop that asks for a password and stops when the correct password is entered.
while [1]: pwd = input("Enter password: ") if pwd [2] [3]: break
!= which breaks on wrong password.The loop runs forever with while True: and breaks when the password equals "secret123".