官术网_书友最值得收藏!

An if-else statement

In the preceding example, we used an if statement to test each condition. In Python, there is an alternative option named the if-else statement. The if-else statement enables testing an alternative condition if the main condition is not true:

check_address = input("Is your address correct(yes/no)? ") 
if check_address == "yes":
print("Thanks. Your address has been saved")
else:
del(address)
print("Your address has been deleted. Try again")

In this example, if the user input is yes, the indented code block under if is executed. Otherwise, the code block under else is executed.

主站蜘蛛池模板: 台州市| 紫金县| 湄潭县| 扶余县| 日喀则市| 盱眙县| 乌审旗| 田林县| 兴隆县| 孝昌县| 南丹县| 江口县| 商丘市| 江口县| 南川市| 张掖市| 英山县| 巴林左旗| 海安县| 商城县| 南京市| 巴里| 孟津县| 治多县| 临湘市| 辽中县| 富宁县| 鄢陵县| 容城县| 宾川县| 唐河县| 太谷县| 夹江县| 逊克县| 永川市| 崇文区| 沿河| 双桥区| 平山县| 阳谷县| 同仁县|