0

bug or not

Strings 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. ... You can use the \n newline character to create line breaks, or, alternatively, create the desired output using three double quotes """. print('1. \n2. \n3. \n4. \n5. \n6. \n7. \n8. \n9.') we also tried various ways of doing it but it doesnt work... so what wrong? code project strings

10th Oct 2021, 12:39 AM
Pierre-Olivier Cartier
Pierre-Olivier Cartier - avatar
4 Antworten
+ 1
print('\n'.join( str(i) + '.' for i in range(1,10)))
10th Oct 2021, 1:04 AM
ubai
ubai - avatar
+ 1
Pierre-Olivier Cartier Your posted concept will work if you remove the spaces between each item. print("1.\n2.\n3.\n.....etc") The computer sees the space as a character which means the result does not match the challenge requirements. To better understand, run/save the attached code. Look at character 32, just because you can't see it does not mean it does not exist. https://code.sololearn.com/cR8q6PcSDb0A/?ref=app
10th Oct 2021, 2:52 AM
Rik Wittkopp
Rik Wittkopp - avatar
0
you should try print(""" 1. 2. 3. 4. 5. 6. 7. 8. 9.""")
10th Oct 2021, 1:15 AM
Kevin Medina Baquero
Kevin Medina Baquero - avatar
0
Kevin Medina Baquero ubai Hi guys Both your codes will work and are well presented, but giving a complete answer without an explanation of the concepts does not help the OP learn.
10th Oct 2021, 2:56 AM
Rik Wittkopp
Rik Wittkopp - avatar