Ok, so I converted each line in a text file into a member of a list by doing the following: chkseq=[line.strip() for line in open("sequence.txt")]
So when I print chkseq I get this:
['3','3']
What I would like is for it to instead look like this:
[3,3]
I know this is possible, I’m just unsure of how! I need them to be intergers, not strings. So if all else fails, that is my main goal in this: create a list from a .txt file whose members are intergers (which would be all the .txt file contained).
Thanks!! -OSFTW
Ok, so I converted each line in a text file into a member of
Share
It looks like you want to interpret the strings as integers. Use
intto do this:It can also be written using
mapinstead of a list comprehension: