Мне нужна помощь с моим кодом NEA для распознавания текста.Я получаю код ошибки «Неожиданный отступ» и мне нужно несколько советов о том, почему я могу получить эту ошибку
def create_account(username,password):
with open("Users.csv", "a", newline="") as csvfile:
appender=csv.writer(csvfile)
appender.writerow([username,password])
import csv
###MENU######MENU######MENU######MENU######MENU######MENU######MENU###
def display_song(artist, song):
print(artist) #Print Name Of Song Artist
words= song.split() #Splits the words of the song
for current_word in words: #
no_of_letters = len(current_word) # Counts the amount of letters in the song name
print(current_word[0]+"_"*(no_of_letters-1)+" ",end="")
def menu(options):
no_of_options = len(options)
print("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\
n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nn===================================================")
print("¦ Please choose from one of the following options ¦")
print("===================================================")
for each_option in range (no_of_options):
print("¦"+str(each_option+1)+") "+options[each_option])
print("===================================================")
user_input=input("¦ Please Enter an option ¦> ")
try:
option_converted_to_integer = int(user_input)
if option_converted_to_integer > 0 and option_converted_to_integer <= no_of_options:
return(option_converted_to_integer)
else:
raise
except:
print(str(user_input) + " is not a valid option, please try again.")
return menu(options)
with open ("Users.csv") as csvfile:
reader=csv.reader(csvfile,delimiter=",")
for row in reader:import csv
import random
###MENU######MENU######MENU######MENU######MENU######MENU######MENU###
def display_song(artist, song):
print(artist) #Print Name Of Song Artist
words= song.split() #Splits the words of the song
for current_word in words: #
no_of_letters = len(current_word) # Counts the amount of letters in the song name
print(current_word[0]+"_"*(no_of_letters-1)+" ",end="")
def menu(options):
no_of_options = len(options)
print("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\
n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n===================================================")
print("¦ Please choose from one of the following options ¦")
print("===================================================")
for each_option in range (no_of_options):
print("¦"+str(each_option+1)+") "+options[each_option])
print("===================================================")
user_input=input("¦ Please Enter an option ¦> ")
try:
option_converted_to_integer = int(user_input)
if option_converted_to_integer > 0 and option_converted_to_integer <= no_of_options:
return(option_converted_to_integer)
else:
song_list.append(row[0])
full_song_list.append(row[0])
artist_list.append(row[0])
def create_account(username,password):
with open("Users.csv", "a", newline="") as csvfile:
appender=csv.writer(csvfile)
appender.writerow([username,password])
###SIGN UP, LOG IN, QUITTING######SIGN UP, LOG IN, QUITTING######SIGN UP, LOG IN, QUITTING######SIGN UP, LOG IN, QUITTING######SIGN UP, LOG IN, QUITTING######SIGN UP, LOG IN, QUITTING######SIGN UP, LOG IN, QUITTING###
print('\n'*69)
menu_options=["Log In","Create an Account","Quit the program"]
selected_options = menu(menu_options)
while selected_options!=len(menu_options):
def game():
song_list=[]
global songlist
full_song_list=[]
global full_song_list
artist_list=[]
global artist_list
point=0
global points
successful_guesses=0
with open ("song names.csv") as csvfile:
reader=csv.reader(csvfile,delimiter=",")
for row in reader:
song_list.append(row[0])
full_song_list.append(row[0])
artist_list.append(row[0])
lives=1
while True:
song_number=random.randint(0,20)
song=song_list[song_number]
song_to_guess=full_song_list[song_number]
#print("DEBUG: ",song_to_guess,"\n")
print(song)
print(artist_list[song_number])
guess=input("Please guess the artist:\n")
song=song.lower()
if guess==song_to_guess:
if lives==2:
print("\nCorrect!\n")
while True:
if user_option==1:
log_in()
while True:
user_option=menu(["Start Game","Exit"])
print(user_option)
if user_option==1:
shown_username=import csv
import random
###MENU######MENU######MENU######MENU######MENU######MENU######MENU######MENU######MENU######MENU######MENU######MENU######MENU######MENU###
def display_song(artist, song):
print(artist) #Print Name Of Song Artist
words= song.split() #Splits the words of the song
for current_word in words: #
no_of_letters = len(current_word) # Counts the amount of letters in the song name
print(current_word[0]+"_"*(no_of_letters-1)+" ",end="")
def menu(options):
no_of_options = len(options)
print("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\
n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n===================================================")
print("¦ Please choose from one of the following options ¦")
print("===================================================")
for each_option in range (no_of_options):
print("¦"+str(each_option+1)+") "+options[each_option])
print("===================================================")
user_input=input("¦ Please Enter an option ¦> ")
try:
option_converted_to_integer = int(user_input)
if option_converted_to_integer > 0 and option_converted_to_integer <= no_of_options:
return(option_converted_to_integer)
else:
raise
except:
print(str(user_input) + " is not a valid option, please try again.")
return menu(options)
with open ("Users.csv") as csvfile:
reader=csv.reader(csvfile,delimiter=",")
for row in reader:import csv
import random
###MENU######MENU######MENU######MENU######MENU######MENU######MENU######MENU######MENU######MENU######MENU######MENU######MENU######MENU###
def display_song(artist, song):
print(artist) #Print Name Of Song Artist
words= song.split() #Splits the words of the song
for current_word in words: #
no_of_letters = len(current_word) # Counts the amount of letters in the song name
print(current_word[0]+"_"*(no_of_letters-1)+" ",end="")
def menu(options):
no_of_options = len(options)
print("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\
n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n===================================================")
print("¦ Please choose from one of the following options ¦")
print("===================================================")
for each_option in range (no_of_options):
print("¦"+str(each_option+1)+") "+options[each_option])
print("===================================================")
user_input=input("¦ Please Enter an option ¦> ")
try:
option_converted_to_integer = int(user_input)
if option_converted_to_integer > 0 and option_converted_to_integer <= no_of_options:
return(option_converted_to_integer)
else:
song_list.append(row[0])
full_song_list.append(row[0])
artist_list.append(row[0])
def create_account (username,password):
with open("Users.csv", "a", newline="") as csvfile:
appender=csv.writer(csvfile)
appender.writerow([username,password])
###SIGN UP, LOG IN, QUITTING######SIGN UP, LOG IN, QUITTING######SIGN UP, LOG IN, QUITTING######SIGN UP, LOG IN, QUITTING######SIGN UP, LOG IN, QUITTING######SIGN UP, LOG IN, QUITTING######SIGN UP, LOG IN, QUITTING###
print('\n'*69)
menu_options=["Log In","Create an Account","Quit the program"]
selected_options = menu(menu_options)
while selected_options!=len(menu_options):
def game():
song_list=[]
global songlist
full_song_list=[]
global full_song_list
artist_list=[]
global artist_list
point=0
global points
successful_guesses=0
with open ("song names.csv") as csvfile:
reader=csv.reader(csvfile,delimiter=",")
for row in reader:
song_list.append(row[0])
full_song_list.append(row[0])
artist_list.append(row[0])
lives=1
while True:
song_number=random.randint(0,20)
song=song_list[song_number]
song_to_guess=full_song_list[song_number]
#print("DEBUG: ",song_to_guess,"\n")
print(song)
print(artist_list[song_number])
guess=input("Please guess the artist:\n")
song=song.lower()
if guess==song_to_guess:"guest"
pass
elif user_option==2:
game()
if user_option==2:
entered_name=input("What is your name?\n")
if selected_options==2:
pass
###LOG IN######LOG IN######LOG IN######LOG IN######LOG IN######LOG IN######LOG IN######LOG IN######LOG IN######LOG IN######LOG IN######LOG IN######LOG IN######LOG IN######LOG IN######LOG IN######LOG IN######LOG IN###
if selected_options==1:
print('\n'*68)
input('Enter your username >')
input('Enter your password >')
pass
menu_options=["Start Game","Quit the program"]
selected_options = menu(menu_options)
if selected_options==1:
def game():
song_list=[]
global songlist
full_song_list=[]
global full_song_list
artist_list=[]
global artist_list
point=0
global points
successful_guesses=0
with open ("song names.csv") as csvfile:
reader=csv.reader(csvfile,delimiter=",")
for row in reader:
song_list.append(row[0])
full_song_list.append(row[0])
artist_list.append(row[0])
lives=1
while True:
song_number=random.randint(0,20)
song=song_list[song_number]
song_to_guess=full_song_list[song_number]
#print("DEBUG: ",song_to_guess,"\n")
print(song)
print(artist_list[song_number])
guess=input("Please guess the artist:\n")
song=song.lower()
if guess==song_to_guess:
if lives==2:
print("\nCorrect!\n")
while True:
if user_option==1:
log_in()
while True:
user_option=menu(["Start Game","Exit"])
print(user_option)
if user_option==1:
shown_username="guest"
pass
elif user_option==2:
game()
if user_option==2:
entered_name=input("What is your name?\n")
if selected_options==2:
pass
###CREATING AN ACCOUNT######CREATING AN ACCOUNT######CREATING AN ACCOUNT######CREATING AN ACCOUNT######CREATING AN ACCOUNT######CREATING AN ACCOUNT######CREATING AN ACCOUNT######CREATING AN ACCOUNT######CREATING AN ACCOUNT###
if selected_options==2:
print('\n'*68)
create_account(input("Enter your desired username >"), input("Enter your passsword >"))
pass
menu_options=["Start Game","Quit the program"]
selected_options = menu(menu_options)
if selected_options==1:
def game():
song_list=[]
global songlist
full_song_list=[]
global full_song_list
artist_list=[]
global artist_list
point=0
global points
successful_guesses=0
with open ("song names.csv") as csvfile:
reader=csv.reader(csvfile,delimiter=",")
for row in reader:
song_list.append(row[0])
full_song_list.append(row[0])
artist_list.append(row[0])
lives=1
while True:
song_number=random.randint(0,20)
song=song_list[song_number]
song_to_guess=full_song_list[song_number]
#print("DEBUG: ",song_to_guess,"\n")
print(song)
print(artist_list[song_number])
guess=input("Please guess the artist:\n")
song=song.lower()
if guess==song_to_guess:
if lives==2:
print("\nCorrect!\n")
while True:
if user_option==1:
log_in()
while True:
user_option=menu(["Start Game","Exit"])
print(user_option)
if user_option==1:
shown_username="guest"
pass
elif user_option==2:
game()
if user_option==2:
entered_name=input("What is your name?\n")
if selected_options==2:
pass
###QUITTING THE GAME######QUITTING THE GAME######QUITTING THE GAME######QUITTING THE GAME######QUITTING THE GAME######QUITTING THE GAME######QUITTING THE GAME######QUITTING THE GAME######QUITTING THE GAME######QUITTING THE GAME###
if selected_options==3:
pass
##STARTING THE GAME###
#Song List
def game():
global song_list
song_list=[]
global full_song_list
full_song_list=[]
global artist_list
artist_list=[]
points=0
global points
successfuI_guesses=0
global successful_guesses
with open ("songs.csv") as csvfile:
reader=csv.reader(csvfile,delimiter=",")
for row in reader:
song_list.append(row[0])
full_song_list.append(row[0])
artist_list.append(row[0])
lives=1
while True:
song_number=random.randint(0,20)
song=song_list[song_number]
song_to_guess=full_song_list[song_number]
#print("DEBUG: ",song_to_guess,"\n")
print(song)
print(artist_list[song_number])
guess=input("Please guess the artist:\n")
song=song.lower()
guess=guess.lower()
if guess==song_to_guess:
if lives==2:
print("\nCorrect!\n")
points+=3
successful_guesses+=1
elif lives==1:
print("\nCorrect!\n")
points=+1
successful_guesses=+1
def SignUp():
userfile = open("Users.csv", "a")
sUser = input("\nChoose a username: ")
sPass = input("Choose a password: ")
sQues = int(input("""
--------------------------------------------------------------------------------
Security Questions:
1. What is/was your first pet's name?
2. Which town were you born in?
3. What is your mother's maiden name?
4. At what age did you buy your first car?
5. How many seasons of Spongebob have you watched?
6. What secondary school did you go to?
--------------------------------------------------------------------------------
Choose a Security Question (1-6): """))
s1 = ("\nWhat is/was your first pet's name?")
s2 = ("\nWhich town were you born in?")
s3 = ("\nWhat is your mother's maiden name?")
s4 = ("\nAt what age did you buy your first car?")
s5 = ("\nHow many seasons of Spongebob have you watched?")
s6 = ("\nWhat secondary school did you go to?")
answered = False
while answered == False:
if sQues == 1:
print(s1)
sAns = input("Answer: ")
if sQues == 4:
print(s4)
sAns = input("Answer: ")
answered = True
if sQues == 5:
print(s5)
sAns = input("Answer: ")
answered = True
if sQues == 6:
print(s6)
sAns = input("Answer: ")
answered = True
WriteLine = sUser + "," + sPass + "," + sAns + "\n"
userfile.write(WriteLine)
userfile.close()
print("\nAccount Created!")
Menu()