Saturday, June 29, 2019

iterating with index using python

""" Dispay resistor colour code values"""
colours = [ "black", "brown", "red", "orange", "yellow",
"green", "blue", "violet", "grey","white" ]
cv = list (enumerate (colours))
for c in cv:
    print(c[0], "\t", c[1])


output:
0        black
1        brown
2        red
3        orange
4        yellow
5        green
6        blue
7        violet
8        grey
9        white

No comments:

Post a Comment

python class topic video