0
My code is wrong but solution is right?
I was doing the exercise where you separate the letter into different lines, and I guess my code is wrong, but the output is exactly the same. What am I doing wrong?
7 Answers
+ 4
Hi, again.
If A, B and C is a characters, then you have to put quotes around everything like:
print("A\nB\nC\nD")
(If the are variables, the its more complicated:
print(str(A) + "\n" + str(B) + "\n" + str(C) + "\n" + str(D))
but I donât think they are...)
Another way is this:
print("A", "B", "C", "D", sep="\n")
and same for variables, of course. And maybe the most simple way is to use a for loop, like this:
for c in "ABCB": print(c)
/Regards Per B đ
+ 3
Hi!
Itâs more easy to help you if you attach a link to your code in your question.
/Regards Per B đ
+ 3
if they are variables, just do:
print(A,B,C,D,sep='\n')
+ 2
check for leading/trailing whitespaces: there shouldn't be any in output... and no leading nor trailing new lines to be valid:
print('A\nB\nC\nD')
0
print(A \n B \n C \n D)
0
please show your code.đ€ we donât know whatâs wrong if we canât even see the code đŹ
0
@python_tip @SoloLearn
played with some #code
đ€
yards = int(input())
def cheer(yard):
if yard < 1:
cheers = "shh"
elif 1 <= yard <= 10:
cheers = "Ra!"*yard
elif yard > 10:
cheers = "High Five"
return cheers
c = cheer(yards)
print (c)