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

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.

主站蜘蛛池模板: 句容市| 孝义市| 顺义区| 双城市| 新营市| 叶城县| 大英县| 增城市| 建湖县| 堆龙德庆县| 讷河市| 江安县| 金山区| 丹巴县| 广饶县| 汽车| 临潭县| 洪江市| 定西市| 兴仁县| 沁水县| 元谋县| 大同县| 南丰县| 千阳县| 昌黎县| 伊川县| 平舆县| 西畴县| 鹤庆县| 元谋县| 青神县| 贵定县| 巧家县| 五常市| 五大连池市| 独山县| 栖霞市| 海盐县| 金湖县| 伊吾县|