+ 2

Why does \n not work?

EDIT: This is now solved, thank you very much It's probably weird to be so excited, but I just defined my first function!! This seemed so difficult for me. Can somebody tell though why the line continuation \n doesn't work and what I could do instead of print(" ") on every line I want to jump? Thank you https://code.sololearn.com/cTRBFaHeS2VV/?ref=app

9th Jan 2023, 11:14 PM
Sarah
15 Antworten
+ 4
Hello, Congratulations on making your first function. I do not know what your code looks like, and therefore I can't tell exactly why it is not working. But, the mistake I had, is that I didn't put "\n" inside speech marks (" "). Which you might have. Can you post your code in here, so it can be analysed and a solution be suggested for you?
9th Jan 2023, 11:18 PM
Lamron
Lamron - avatar
+ 4
😎 Show us your code
9th Jan 2023, 11:19 PM
SoloProg
SoloProg - avatar
+ 3
Thank you SoloProg and Lamron I will definitely try out both 😁👍
9th Jan 2023, 11:32 PM
Sarah
+ 2
Huh, something went wrong there. Here's the code now. Sorry Lamron and SoloProg
9th Jan 2023, 11:21 PM
Sarah
+ 2
Use print (f"[ h:{h} w:{w} d:{d} ]") instead of print("h:" + str(h)+" w:"+str(w)+" d:"+"33.0")
9th Jan 2023, 11:28 PM
SoloProg
SoloProg - avatar
+ 2
Try this for each one of them: print("\n[]\n") calc_expedit(1,1) print("\n[][]\n") calc_expedit(2,1) calc_expedit(2,1) print("\n[][]\n") calc_expedit(1,2) calc_expedit(1,2) \n before [] will make it so there is a line break between the previous [] and this []. \n after [] will make it, so there's a line break after this line. Just put \n at the end/start of the strings, where boxes are
9th Jan 2023, 11:29 PM
Lamron
Lamron - avatar
+ 1
So, you want each of [ ] on a new line? UPD: oh, I see what you want, give me a minute
9th Jan 2023, 11:24 PM
Lamron
Lamron - avatar
11th Jan 2023, 4:35 AM
Lochard
Lochard - avatar
0
Lamron , no, I would like it to look how it looks now but would like to not have to use a print(" ") every single time
9th Jan 2023, 11:26 PM
Sarah
0
First: print("\n") Is printing new line Second: Why you want print "[]" ?
11th Jan 2023, 1:34 AM
Václav Dostál
Václav Dostál - avatar
0
Thanks Lochard that's a lot shorter 😁
11th Jan 2023, 1:43 PM
Sarah
0
Václav Dostál The "[]" are the boxes I need to fit into the Kallax Cubbie. I need to see the arrangement
11th Jan 2023, 1:58 PM
Sarah
0
print("Hello\nWorld!")
11th Jan 2023, 2:27 PM
Janith Umeda
Janith Umeda - avatar
0
Sarah I made one that requires different input. https://code.sololearn.com/cyIBw8MFYwgH/?ref=app
11th Jan 2023, 4:05 PM
Lochard
Lochard - avatar
0
O Abi
11th Jan 2023, 6:46 PM
jjjajjji
jjjajjji - avatar