dropdown menu

Back To Home

Wednesday, November 13, 2019

python enumerate concept

Enumerate has 2 variables that very useful - count and element.
count - count number of line starting from 0. count+1 so that starting from 1.
element - is the full content of the line e.g.saya or dia and etc.

Code:

with open("line.txt") as f:
   for count, element in enumerate(f):
        pass
   print (count+1)
   print(element)

line.txt:
saya
dia
a
130 30 80
255 240 255
                                 

No comments:

Post a Comment