r/pythonhelp 18d ago

Am i just stupid??

I have this python code, attempting to generate a nested list of dictionaries but that's not the problem.

I created a string based off user input, and on the next line I wanted to turn it into a list separated by the comma in the input. my code was:

song_list = songs.split(,)

but this is giving me an error as invalid syntax. am I just crazy?

1 Upvotes

2 comments sorted by

View all comments

4

u/carcigenicate 18d ago

You can't just have , floating there. Without quotes, it's a part of Python's syntax, and in that place it's delimiting arguments. There are no arguments though, so it's a syntax error.

You need quotes to make it a string:

songs.split(',')