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

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.

主站蜘蛛池模板: 中宁县| 南昌市| 泸州市| 太白县| 云阳县| 安乡县| 全州县| 太和县| 赞皇县| 西乌珠穆沁旗| 乡宁县| 纳雍县| 沅江市| 扎鲁特旗| 永清县| 阿瓦提县| 北海市| 兰西县| 安塞县| 巢湖市| 金平| 炎陵县| 凤翔县| 白河县| 德令哈市| 葫芦岛市| 黎平县| 台中市| 北宁市| 赣州市| 丰城市| 济阳县| 于都县| 谷城县| 博兴县| 夏河县| 河西区| 渑池县| 漯河市| 葫芦岛市| 托里县|