0
How can I make this more efficient : python
Rather than going one by one how can I make this question easier Question: make a leaderboard list 1-9 Eg; 1. 2. 3. Etc. My code: print("1.") print("2.") print("3.") print("4.") print("5.") print("6.") print("7.") print("8.") print("9.")
8 odpowiedzi
+ 3
either by using a loop or by outputting only one string:
for i in range(1,10):
print(str(i)+".")
or
print("1.\n2.\n3.\n4.\n5.\n6.\n7.\n8.\n9.")
"\n" is the new line char
+ 2
Use a for loop
for i in range(10):
print(i)
+ 2
visph ,
there is a "n" missing in print("1.\n2.\3.\n4.\n5.\n6.\n7.\n8.\n9.") just before the number 3. ;-)
+ 1
Lothar thank's for the typo: corrected ;)
+ 1
Loops must be a better way to do this because in that you need not to use new line character
0
visph i tried the new line char but i think i did it wrong since it ended like this
1.
2.
3.
Etc
Where there was a space after the first one. How would i fix that
0
because you put space after (and maybe before) \n... the expected output must have no spaces at all ;P
0
visph thank you !