just letting you know that I am not that experience with programming
For the program I am doing, it generates a list of anime recommendations by going through a survey style questions and having a CSV file storing info about the anime such as the genre.
However, when running through the program, I wanted to test if the syntax error will occur when doing the questions and ends up at the printing the error after doing all of the questions. What I was hoping it would do is I to have the syntax error will pop up when putting the input incorrectly.
This the what i have done:
if adventure == 'yes':
with open("AnimeGenre3.csv", 'r', newline='') as f:
for row in csv.reader(f):
if row[4] == 'yes':
anime = str(row[1])
looping = False
if anime not in anime_list:
anime_list.append(anime)
else:
print('''
There seems to be a problem in one of the questions
''')
Let's say, 'do you like anime', and you enter 6, the syntax error thing pops up and redo the question. But after doing all the questions and generates the list of anime, that's where it pops up.
Another issue is how do I start the program again after finishing the questions and printed the recommended anime. It asks if you want to start again, but it ends up not doing it. This is what I did.
StartAgain = str(input('Do you like to start again; yes or no: '))
if StartAgain == 'yes':
print('''
Let's begin ''')
break
if StartAgain == 'no':
print('thank you for coming')
else:
print('''
Sorry Man got to do it again''')
# an if statement if the user wants to start again
# this should rerun the program.
Now, this is the full program that I have done so far, honestly need to find a way to make it simpler, and hopefully, my annotations are good enough.
import csv
anime_list = []
#in the csv AnimeGenre3.csv it contains information such as the animes, the number of
episodes and genres
#printing information about the program.
#has an if statement to identify if it user wants to start the program.
looping1 = True
looping2 = True
print('This is a program that identifies specific anime for you')
while looping1 == True:
begin = str(input('Do you like to start; yes or no: '))
if begin == 'yes':
print('''
Let's begin
''')
break
if begin == 'no':
print('thank you for coming')
else:
print('''
Sorry Man got to do it again
''')
#this section is where the program ask the user questions from there
# it will identify, the genres the user is interested in.
while looping2 == True:
action = str(input('Do you like action; yes or no: '))
adventure = str(input('Do you like adventure; yes or no: '))
print('')
print('recommended anime')
#having to use if statements to find any anime that either say "yes" in the CSV file
# it sorts out all of the sorts that the user said yes to.
# It goes through the rows to identify all of the user genres that say yes
# it should print out the recommend anime
# this prints out a long list of anime
if action == 'yes':
with open("AnimeGenre3.csv", 'r', newline='') as f:
for row in csv.reader(f):
if row[3] == 'yes':
anime = str(row[1])
looping = False
if anime not in anime_list:
anime_list.append(anime)
if adventure == 'yes':
with open("AnimeGenre3.csv", 'r', newline='') as f:
for row in csv.reader(f):
if row[4] == 'yes':
anime = str(row[1])
looping = False
if anime not in anime_list:
anime_list.append(anime)
else:
print('''
There seems to be a problem in one of the questions
''')
# if there is a syntax error within the program, it should pop up to the user saying this
print(anime_list)
StartAgain = str(input('Do you like to start again; yes or no: '))
if StartAgain == 'yes':
print('''
Let's begin ''')
break
if StartAgain == 'no':
print('thank you for coming')
else:
print('''
Sorry Man got to do it again''')
# an if statement if the user wants to start again
# this should rerun the program.
I hope this makes sense.
Thanks
Aucun commentaire:
Enregistrer un commentaire