Help!
A weird situation:
I was coding the project for school and all of a sudden the following error appeared:
SyntaxWarning: str indices must be integers or slices, not tuple; perhaps you missed a comma?
But the culprit is right according to me. Here’s the culprit:
team=[“1-Shedinja”,“55-Charizard”,[“69-Mew”,“70-Mew”,[“75-Mew”,“79-Mew”]],[“25-Squirtle”,“30-Squirtle”[“35-Squirtle”,“20-Squirtle”],“39-Squirtle”],“120-Arkoos”,“200-Vaporeon”,[“220-Zacian”,“225-Zacian”,[“230-Zacian”,“240-Zacian”],“235-Zacian”]]
PLEASE HELP! If you solve it, you’ll get a digital present from me!
There is a comma missing in "30-Squirtle"["35-Squirtle"
, between the "
and the [
.
2 Likes
I didn’t see that, thank you!
If you break long lists like this up into multiple lines this kind of
thing can be easier to see.
team=[
"1-Shedinja",
"55-Charizard",
[
"69-Mew",
"70-Mew",
["75-Mew", "79-Mew" ]
],
[
"25-Squirtle",
"30-Squirtle"
["35-Squirtle","20-Squirtle"],
"39-Squirtle"
],
"120-Arkoos",
"200-Vaporeon",
[
"220-Zacian",
"225-Zacian",
["230-Zacian","240-Zacian"],
"235-Zacian"
]
]
Exactly where you break things is up to you, but a regular pattern
helps. Also, Python allows a trailing comma in lists, eg:
[
"25-Squirtle",
"30-Squirtle"
["35-Squirtle","20-Squirtle"],
"39-Squirtle",
],
See the trailing comma on the second last line above? If you’re always
expecting a comma, the missing one 2 lines higher up is more obvious.
1 Like