Skip to content
Sign upLog in
← Back to Community

IndexError

Profile icon
ggigabyte

Just run it and you'll see. I've no clue where's the bug and why so please help me!

Voters
Profile icon
OSoft
Profile icon
ggigabyte
Comments
hotnewtop
Profile icon
c4syner

If the goal of the elif block where your error is occurring is to put the variable cmd into a list of characters. Then set ansnum = 0 rather than ansnum = 4

Profile icon
c4syner

Could you explain what

elif "ans" in cmd: ansnum = 4 answer = list() for i in range(len(cmd)): print(i) answer.append(cmd[ansnum]) ansnum += 1 print(answer)

does?