List of data. Python

2

Lists in Python

I've been studying a bit and I have a doubt. I saw a video where the tutor gives an example of a list:

year = [1950,1951,1952, ..., 2100]


Enter the points (...) to follow up, but I get the error that it is not possible and it is a syntax error ... It is possible to enter the points or it is just an example of continuity. I appreciate your attention:)

    
asked by Alejandro Bec 14.11.2016 в 03:16
source

2 answers

3

Those points are figurative to give an example. A valid code equivalent would be this:

year = list(range(1050, 2101))

The range with two parameters sends an iterator from argument1 to argument2 - 1. That's why I put the 2101 .

I hope I have helped you.

Greetings!

    
answered by 14.11.2016 / 03:23
source
1

Exactly, those ellipses are just to give an example of the elements that exist in the list or arrangement. In that case it is implied that there are elements from 1950 to 2100 adding one by one.

The line of code that I leave "Genarito" will help you to write all those elements in the arrangement, I'll also let you know how to print them.

year = list(range(1050, 2101))
for x in year:
    print year

Greetings, I hope it helps.

    
answered by 15.11.2016 в 17:52