+ 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?
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)))
+ 1
Try this:-
print("1.\n2.\n3.\n4.\n5.\n6.\n7.\n8.\n9.")
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")
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.
0
Im a beginner im really confused rn i dont understand anything lel
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..
0
So mine was wrong just cuz i used the " " one every single one?ty anyways
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.
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
0
This would do the job i guess:
**********
for i in range(1,10):
print(str(i)+'.')
**********
0
print(*range(1, 10), "", sep=".\n")
# Hope this helps
0
print("""1.2.3.4.5.6.7.8.9.""")
0
It is correct actually
0
You know-
0
He is stuck in question strings
0
Did you know about challenge "leaderboard"?
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
0
Yes
0
Yes
0
Try adding , in the line between 1.\n,2.\n