April 2017
Beginner to intermediate
312 pages
7h 23m
English
In the preceding example, the program executes any piece of code under the else block for any user input other than yes that is if the user pressed the return key without providing any input or provided random characters instead of no, the if-elif-else statement works as follows:
check_address = input("Is your address correct(yes/no)? ") if check_address == "yes": print("Thanks. Your address has been saved") elif check_address == "no": del(address) print("Your address has been deleted. Try again") else: print("Invalid input. Try again")
If the user input is yes, the indented code block under the if statement is executed. If the user input is no, the indented code block under elif (else-if) is executed. If the ...
Read now
Unlock full access