Skip to content
Advertisement

opening txt file and creating lists from the txt file

JavaScript

I’m trying to Read the file “covid.txt” into two lists. The first list should contain all the “day” values from the file. The second list should contain all the “new cases” values.

my list in column

JavaScript

I needed to be this way

JavaScript

I have tried so many different things I’m new to Python and trying to figure out how to start this. anyone can lead me to the right direction ?

Advertisement

Answer

Assuming your data file has all of those numbers in one long line, this should work:

JavaScript

Followup

Given this data:

JavaScript

My code produces this result:

JavaScript

which is exactly what you said you wanted.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement