blob: 1722a6bfa60b733dcd84e88c6c7a037b3154eef6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# Option 1: add explicit 'else'
def myfunc(shall_continue: bool, shall_exit: bool):
if shall_continue:
if input("Are you sure?") == "y":
print("Moving on.")
else:
pass
elif shall_exit:
print("Exiting.")
# Option 2: extract function
def user_confirmation():
if input("Are you sure?") == "y":
print("Moving on.")
def myfunc2(shall_continue: bool, shall_exit: bool):
if shall_continue:
user_confirmation()
elif shall_exit:
print("Exiting.")
|