0

I want to create a list that outputs something like this:

  1. string1
  2. string2
  3. string3
  4. string4

but the number at the beginning to be a number that is a variable that incrementally increases by one in the loop.

HarryMoy
  • 196
  • 2
  • 17
  • possible duplicate of [Accessing the index in Python for loops](http://stackoverflow.com/questions/522563/accessing-the-index-in-python-for-loops) – n.st Dec 02 '13 at 10:55

1 Answers1

3

Try something like this:

for i, s in enumerate( ("string1", "string2", "string3"), start = 1 ):
    print "{}. {}".format( i, s )
svk
  • 5,604
  • 15
  • 21