\t not working

A

Alex Pavluck

I am just learning Python and I am using the book, "Thinking like a
Computer Scientist". There is an exercise that I am not able to get
working and it is really easy so I thought I would ask for help here.


Q: As an exercise, write a single string that:
Procuces
this
output.


A?
print "produces",'\n',"\t","this","\n","\t","output."
 
B

Brian Blais

Alex said:
I am just learning Python and I am using the book, "Thinking like a
Computer Scientist". There is an exercise that I am not able to get
working and it is really easy so I thought I would ask for help here.


Q: As an exercise, write a single string that:
Procuces
this
output.


A?
print "produces",'\n',"\t","this","\n","\t","output."

You could use:

print "produces \n\t this \n\t\t output"



bb
 
A

Alex Pavluck

Sorry, I just realized that if I run it as a script it just drops a
line and doesn't tab but if I run it from the shell it outputs
perfectly. Thanks for the help.
 
B

bruno at modulix

Alex said:
I am just learning Python and I am using the book, "Thinking like a
Computer Scientist". There is an exercise that I am not able to get
working and it is really easy so I thought I would ask for help here.


Q: As an exercise, write a single string that:
Procuces
this
output.


A?
print "produces",'\n',"\t","this","\n","\t","output."

Which results in:
produces
this
output.

I think the problem should be *really* obvious. Hint : count the "\t".
 
S

Sybren Stuvel

Alex Pavluck enlightened us with:
Q: As an exercise, write a single string that:
Procuces
this
output.


A?
print "produces",'\n',"\t","this","\n","\t","output."

Just nitpicking, since you already got your answer, but that's not a
single string ;-)

Sybren
 
A

Alex Pavluck

ha ha...good point. I didn't realize that you could run it all
together. I guess the "single string" part should have been a tip off.
Anyway, more questions to come soon. Thanks everyone!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top