2021-01-27

Why won't an item accessed from a list become a string?

In a program I'm making, I need to make a variable equal to a specific item in a list, relying on a counting variable, like this: x = list[counter]. I need x to be a string, and since all the items in the list are already strings.

However, when I run this code, x becomes, presumably, an integer. (At least, it does not become a string. It runs an error when I try to use it as a string.) While I am dealing with numbers in the list, they are strings. Even if I try casting x as a string, or making a new variable, like y = str(x), it still does not output a string. Anyone know why this is happening or how I can fix it?



from Recent Questions - Stack Overflow https://ift.tt/39j2xA8
https://ift.tt/eA8V8J

No comments:

Post a Comment