Segment code not executing

I’m creating a book recommendation program, and I have a function that checks the age of the user and what genre they choose, however when I run the program, it only works for the younger age group and genres. It is essentially the same code for each age group just changed to fit the user. The thing being printed is the list of the books. Please help!
P.S I’m new to coding so pls don’t rip me to shreds in the replies as people usually do haha
image

not sure what your problem is exactly, but .lower() on the strings here is redundant. I think you mean

genre.lower() == "fantasy"

etc.

2 Likes

The sep= is also redundant

No it’s not… Did you confuse sep with end?

End is not needed also

I know. That’s why I asked if you got them confused.

They are unpacking (what I’m guessing is a list) and printing them out on separate lines. That’s why they used sep.

oh thank you! someone on here told me to put it as that lol

If all you do is print a string sep or end are not needed,

But they aren’t printing a string… They’re unpacking a list and printing that.

Just look at this code:

someList = ['hi', 'ehllo']
# example list

print(*someList)
# without sep prints on the same line

print(*someList, sep='\n')
# with sep prints on seperate lines

So no, the sep is not useless in this case. Feel free to run this code…

3 Likes

the third removed cousin we don’t talk to anymore for religious reasons:

someList = ['hi', 'ehllo']
print(' '.join(someList))

print('\n'.join(somList))
2 Likes

You are right, that horrible red color * looked like " even with my glasses on.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.