I have a question about this im stuck | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

I have a question about this im stuck

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. I did this and its telling me its wrong print(1. \n2. \n3. \n4. \n5. \n 6. \n7. \n8. \n9. \n) Can someone tell me what im doing wrong i really dont understand lel i tried the """ and it still didnt work im confused?

28th Mar 2021, 9:02 PM
JustNobody
24 Answers
+ 2
JustNobody You can use this code. for i in range(1,10): print(i,".",sep="") OR, print("\n".join(str(i)+"." for i in range(1,10)))
30th Mar 2021, 10:38 AM
ᗩηιηɗуα ᗩɗнιкαяι
+ 1
Try this:- print("1.\n2.\n3.\n4.\n5.\n6.\n7.\n8.\n9.")
30th Mar 2021, 11:38 AM
Shobhit :)
Shobhit :) - avatar
0
I think you are adding space which may not needed and also last new line after 9... and add between quotes print("1.\n")
28th Mar 2021, 9:12 PM
Jayakrishna 🇮🇳
0
i believe you need the leaderboard contents to be in quotes or double quotes. example: list1 = “1. \n2. \n3. \n4. \n5. \n6. \n7. \n8. \n9. ” print(list1) list2 = ‘1. \n2. \n3. \n4. \n5. \n6. \n7. \n8. \n9. ‘ print(list2) print(“1.”, ”2.”, ”3.”, ”4.”, ”5.”, “6.”, ”7.”, ”8.”, “9.”, sep=“\n”) you could also do this with a loop or list comprehension as well.
28th Mar 2021, 9:20 PM
you are smart. you are brave.
you are smart. you are brave. - avatar
0
Im a beginner im really confused rn i dont understand anything lel
28th Mar 2021, 9:32 PM
JustNobody
0
So pls revise lesson.. print("1.") prints 1. Goes to next line.Similarly print 2 to 9.. but Instead of using 10 statement,, you can combine by adding \n between.. like print("1.\n2." ) prints 1. 2. In separate lines..
28th Mar 2021, 9:39 PM
Jayakrishna 🇮🇳
0
So mine was wrong just cuz i used the " " one every single one?ty anyways
28th Mar 2021, 9:42 PM
JustNobody
0
It's not wrong, the idea is right. It's just a syntax fail, you gotta check that up. The print() method requires quotes (double or single, w/e) for printing strings given as a value to it. eg. print ('1.\n2.\n') # and so on... JustNobody and it doesn't need to be in every single one of the characters, tho, just around the whole string.
29th Mar 2021, 12:21 AM
philipep
philipep - avatar
0
Print by string, print(''' 1. 2. 3. 4. 5. 6. 7. 8. 9. ''') Im slove this problem by this method, I hope I'm clear now
29th Mar 2021, 4:17 AM
AMAN DHIMAN
AMAN DHIMAN - avatar
0
This would do the job i guess: ********** for i in range(1,10): print(str(i)+'.') **********
29th Mar 2021, 8:09 PM
Alireza
Alireza - avatar
0
print(*range(1, 10), "", sep=".\n") # Hope this helps
30th Mar 2021, 4:57 AM
Calvin Thomas
Calvin Thomas - avatar
0
print("""1.2.3.4.5.6.7.8.9.""")
30th Mar 2021, 5:08 AM
Huhu
0
It is correct actually
30th Mar 2021, 5:09 AM
Huhu
0
You know-
30th Mar 2021, 10:41 AM
Huhu
0
He is stuck in question strings
30th Mar 2021, 10:41 AM
Huhu
0
Did you know about challenge "leaderboard"?
30th Mar 2021, 10:41 AM
Huhu
0
Exactly, Muhammad Faris Bin Abdul Hakim. He's stuck in a question about strings and people here showing off with so many complex codes lool
30th Mar 2021, 10:47 AM
philipep
philipep - avatar
0
Yes
30th Mar 2021, 10:48 AM
Huhu
0
Yes
30th Mar 2021, 10:48 AM
Huhu
0
Try adding , in the line between 1.\n,2.\n
30th Mar 2021, 5:51 PM
Gamer Stand
Gamer Stand - avatar