Hello I am really new to learning python, and I am getting confused working with lists.
I wrote the following and I get the following
TypeError: list indices must be integers, not str
My code is:
numlist = list()
listy = ['341', '22', '1803']
for i in listy:
numlist = int(listy[i])
So in this program I am trying to write, part of it includes a list of numbers. I want to take those numbers and append them to another list (numlist) that converts each entry in the first list to an integer type.
So I thought I needed to step through each entry in listy. Does the problem stem from 'i' referencing the entry (ex: '341' and not index 0)? If so...how do you refer to the index? I thought that's what I was doing, but clearly not :(.
Any help would be much appreciated. I looked through some other questions posted to Stack with the same Type Error but I'm so new to this that they all just confused me further.