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?

8th Feb 2021, 10:40 PM
Alita Tripp
Alita Tripp - avatar
7 ответов
+ 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 🙂
8th Feb 2021, 10:57 PM
Per Bratthammar
Per Bratthammar - avatar
+ 3
Hi! It’s more easy to help you if you attach a link to your code in your question. /Regards Per B 🙂
8th Feb 2021, 10:52 PM
Per Bratthammar
Per Bratthammar - avatar
+ 3
if they are variables, just do: print(A,B,C,D,sep='\n')
8th Feb 2021, 11:10 PM
visph
visph - avatar
+ 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')
9th Feb 2021, 3:05 PM
visph
visph - avatar
0
print(A \n B \n C \n D)
8th Feb 2021, 10:54 PM
Alita Tripp
Alita Tripp - avatar
0
please show your code.🤭 we don’t know what’s wrong if we can’t even see the code 😬
9th Feb 2021, 3:01 PM
Wilbur Jaywright
Wilbur Jaywright - avatar
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)
10th Feb 2021, 9:31 AM
HERAWATI
HERAWATI - avatar