In the following code, the if statement is reached and runs fine. The elif statement however seems to have no effect. When the script is run, when the conditions for the elif statement are met, nothing happens and when I press return button twice the script just keeps going skipping the elif statement altogether.
My code:
print("If you want to name this window press 1, if you want to describe it press 2")
if input() == "1":
print("Please enter this window's title:")
current_window_title = input()
print("Do you also want to describe this window? P.S: You can do this later.)")
if input().lower() == "yes":
print("Please enter this window's description:")
current_window_description = input()
else:
current_window_description = "None"
elif input() == "2":
print("Please enter this window's description:")
current_window_description = input()
print("Do you also want to give this window a title? P.S: You can do this later.")
if input().lower() == "yes":
print("Please enter this window's title:")
current_window_title = input()
>Solution :
Because you got an input from the user and in the same range if and this amount of input is not available in elif you can do these two things and it will work properly:
print("If you want to name this window press 1, if you want to describe it press 2")
inp = input()
if inp == "1":
print("Please enter this window's title:")
current_window_title = input()
print("Do you also want to describe this window? P.S: You can do this later.)")
if input().lower() == "yes":
print("Please enter this window's description:")
current_window_description = input()
else:
current_window_description = "None"
elif inp == "2":
print("Please enter this window's description:")
current_window_description = input()
print("Do you also want to give this window a title? P.S: You can do this later.")
if input().lower() == "yes":
print("Please enter this window's title:")
current_window_title = input()
or :
print("If you want to name this window press 1, if you want to describe it press 2")
if input() == "1":
print("Please enter this window's title:")
current_window_title = input()
print("Do you also want to describe this window? P.S: You can do this later.)")
if input().lower() == "yes":
print("Please enter this window's description:")
current_window_description = input()
else:
current_window_description = "None"
if input() == "2":
print("Please enter this window's description:")
current_window_description = input()
print("Do you also want to give this window a title? P.S: You can do this later.")
if input().lower() == "yes":
print("Please enter this window's title:")
current_window_title = input()