Problems with printing variables with successive names

  • A+
Category:Languages

I am new to Python so apologies in advance. Here is the code that I have problems with:

x = 1  v1 = "First" v2 = "Second" v3 = "Third" v4 = "Forth" v5 = "Fifth" v6 = "Sixth" v7 = "Seventh" v8 ="Eighth" v9 = "Ninth" v10 = "Tenth"  for x in range (1,11):     print("v"+str(x)) 

This is the returned result:

v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 

And this is what I want the returned result to be:

First Second Third Fourth Fifth Sixth Seventh Eighth Ninth Tenth 

How could I print the content of increasingly named variables?

 


Try this. Just store the strings in a list and print it:

x = 1 store_1 = ["First", "Second", "Third", "Fourth", "Fifth", "Sixth", "Seventh", "Eighth", "Ninth","Tenth"]  for x in store_1:     print(x) 

Comment

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: