Skip to content
Sign upLog in
← Back to Community

Python Question

Profile icon
Elizabeth_Mason

My computer science teacher wants me to put this phrase in one line of code. But I have no idea what to do. I have tried every possible way I could think of. Can anyone help me?

Screenshot 2019-09-05 at 5.45.42 PM

Answered by theangryepicbanana [earned 5 cycles]
View Answer
Voters
Profile icon
HARLEYHELMICK
Profile icon
PashyonMosby
Profile icon
Elizabeth_Mason
Comments
hotnewtop
Profile icon
theangryepicbanana

try using \n and \t in the string

Profile icon
Elizabeth_Mason

@theangryepicbanana
none of them will work. This is what I get every time...
image

Profile icon
theangryepicbanana

@Elizabeth_Mason can I see what you typed in?

Profile icon
Elizabeth_Mason

@theangryepicbanana
sure give me a few minutes

Profile icon
Elizabeth_Mason

Screenshot 2019-09-05 at 6.01.14 PM


Screenshot 2019-09-05 at 6.01.04 PM

Screenshot 2019-09-05 at 6.00.33 PM

Screenshot 2019-09-05 at 6.00.21 PM

Screenshot 2019-09-05 at 6.00.09 PM

Screenshot 2019-09-05 at 5.59.57 PM

Screenshot 2019-09-05 at 5.59.46 PM

Profile icon
theangryepicbanana

@Elizabeth_Mason you don't need to add extra strings; the \n inserts a "new line" and the \t inserts a tab

Profile icon
Elizabeth_Mason

@theangryepicbanana
So then how do I solve it?

Profile icon
theangryepicbanana

@Elizabeth_Mason if I did print("A lightning flash:\nbetween the forest trees"), I'd get the following output:

A lightning flash: between the trees

Knowing that, are you able to figure out the rest?

Profile icon
Elizabeth_Mason

@theangryepicbanana
Yea thank you...If I need anymore help I will contact you. Thank you!

Profile icon
theangryepicbanana

@Elizabeth_Mason No problem! (also mark my comment as "best answer" is it helped)

Profile icon
Elizabeth_Mason

@theangryepicbanana
Hey I have tried with the \n and \t ... I don't know what else to do.

Screenshot 2019-09-05 at 6.51.06 PM


Screenshot 2019-09-05 at 6.50.11 PM

Profile icon
theangryepicbanana

@Elizabeth_Mason you don't need any spaces after the \n

Profile icon
Elizabeth_Mason

@theangryepicbanana
no correct answer

Profile icon
Elizabeth_Mason

I will ask my teacher through email...or I will ask her tomorrow

Profile icon
theangryepicbanana

@Elizabeth_Mason ok, maybe she mistyped something for the assignment

Profile icon
Elizabeth_Mason

@theangryepicbanana
Maybe...Thanks again for your help!!! :):):)

Profile icon
Muhammad_SJC

@theangryepicbanana
you know you can save all the hassle by typping the message inside 3 speech marks:

print("""A lightning flash: between the forest trees I have seen water. -Shiku""")
Profile icon
Muhammad_SJC

It actually works

Profile icon
vianneyt

koman on piton

Profile icon
josephchuang

print("A lightning flash: \n between the forest trees \n I have seen water . \n \t -Shiki

Profile icon
Elizabeth_Mason

@josephchuang
I figured it out...there was no space between - Shiki...Thanks, everyone for the help