I'm an absolute amateur at coding in Python and I always end up getting this "IndentationError: expected an indented block after 'elif' statement on line 36" whenever I try to run my log-in program.
Can someone tell me what I'm doing wrong?
# Gelos Enterpises Login
import csv
import sys
import string
import random
import secrets
password_length = 10
print(secrets.token_urlsafe(password_length))
def main():
menu()
def menu():
print("************Gelos Enterpises Login**************")
print()
choice = input("""
A: Please Register
B: Login
C: Logout
D: Generate Password
Please enter your choice: """)
if choice == "A" or choice == "a":
register()
elif choice == "B" or choice == "b":
login()
elif choice == "C" or choice == "c":
sys.exit
elif choice == "D" or choice == "d":
else:
print("You must only select either A or B")
print("Please try again")
menu()
def register():
pass
def login():
pass
# the program is initiated, so to speak, here
main()
CodePudding user response:
# Gelos Enterpises Login
import csv
import sys
import string
import random
import secrets
password_length = 10
print(secrets.token_urlsafe(password_length))
def main():
menu()
def menu():
print("************Gelos Enterpises Login**************")
print()
choice = input("""
A: Please Register
B: Login
C: Logout
D: Generate Password
Please enter your choice: """)
if choice == "A" or choice == "a":
register()
elif choice == "B" or choice == "b":
login()
elif choice == "C" or choice == "c":
sys.exit
elif choice == "D" or choice == "d":
# The problem is here:
# You need a statement here, if you want to do nothing, you could just use a pass
pass
else:
print("You must only select either A or B")
print("Please try again")
menu()
def register():
pass
def login():
pass
# the program is initiated, so to speak, here
main()
python
authentication
CodePudding user response:
its because theres nothing in the elif block before that. If you don't want it to output anything just put a comment on that line
elif choice == "C" or choice == "c":
sys.exit
elif choice == "D" or choice == "d":
#this is your missing code!
else:
print("You must only select either A or B")
print("Please try again")
menu()