Skip to main content

You can simply use counta variable such as count to count the number of elements in the list:

ints = [8, 23, 45, 12, 78]
count = 0
for i in ints:
    count = count + 1
    print('item #{} = {}'.format(count, i))

You can simply use count variable to count the number of elements in the list

ints = [8, 23, 45, 12, 78]
count = 0
for i in ints:
    count = count + 1
    print('item #{} = {}'.format(count, i))

You can simply use a variable such as count to count the number of elements in the list:

ints = [8, 23, 45, 12, 78]
count = 0
for i in ints:
    count = count + 1
    print('item #{} = {}'.format(count, i))
Source Link
Rahul
  • 179
  • 2
  • 4

You can simply use count variable to count the number of elements in the list

ints = [8, 23, 45, 12, 78]
count = 0
for i in ints:
    count = count + 1
    print('item #{} = {}'.format(count, i))