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

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.

主站蜘蛛池模板: 平邑县| 广安市| 温州市| 磐安县| 容城县| 桐梓县| 余姚市| 炉霍县| 浙江省| 台南市| 得荣县| 张家港市| 陵水| 桐乡市| 琼海市| 安顺市| 灵武市| 洞头县| 兖州市| 车致| 东乌珠穆沁旗| 荥经县| 汉阴县| 顺义区| 桓仁| 屏边| 金昌市| 岑溪市| 郑州市| 宁阳县| 平塘县| 东阿县| 海伦市| 河曲县| 玉树县| 远安县| 南京市| 子洲县| 老河口市| 阜宁县| 宜川县|