+ 5
How do I solve this?
You need to make a program for a leaderboard. The program needs to output the numbers 1 to 9, each on a separate line, followed by a dot: 1. 2. 3. ...
10 Respuestas
+ 13
print(*range(1, 10), sep=".\n", end=".")
https://code.sololearn.com/cUf1BnJlGwSm
+ 6
You can use "for":
for i in range(1, 10):
print(str(i) + '.')
+ 2
I did it!!!!!
print ('1.' '\n2.' '\n3.' '\n4.' '\n5.' '\n6.' '\n7.' '\n8.' '\n9.')
Python 3 😉
+ 2
Mariana lima 👍
here is another option.
def leaderboard(n):
for i in range(n):
string=f'{i+1}.\n'
print(string)
if __name__=="__main__":
n=9
leaderboard(n)
+ 2
Aathisankar Good idea, but he comma in the print() function inserts an unwanted space before the period. The default separator is a space unless you specify something else with sep=
+ 2
Aathisankar Yes. print(x, sep='.') and print(x, '.', sep='') both do the same thing.
+ 1
for i in range(9):
print(i+1,'.')
+ 1
Then this will do
for i in range(9):
print(I+1,'.',sep='')
+ 1
for u in range(1,10):
print (u , ".")