Ask your own question, for FREE!
MIT 6.189 A Gentle Introduction to Programming Using Python (OCW) 13 Online
OpenStudy (anonymous):

Curious how to write code on several lines. For example, in the exercise with tic tac toe lines. I can only get them on one line and not as a tic tac toe table.

OpenStudy (anonymous):

Hi BreeAnne, Can you cut and paste the lines of code that you have entered? Or attach your tictactoe.py file?

OpenStudy (anonymous):

Try using an IDE for that. You can use IDLE ( WIndows and Linux ) or even VIM and gedit as your IDE for Linux.

OpenStudy (konradzuse):

Well if you mean display output on several lines... In Java there is Println and Print. Print just prints on one line, while Println prints on multiple lines. I believe this is the same or about for most languages. C uses printf I believe.

OpenStudy (anonymous):

If it is something contained in parentheses you can just continue on the next line like this some random code to do something (10, 23, 556, 78, 32, 45, 78) Other wise you can use the backslash character "\" like below some random code that does something but the line is long so \ some more random code that is part of the same line

OpenStudy (anonymous):

to have things output from a script onto multiple lines, use multiple lines of "print" commands. each "print" command will output on a new line. let me know if this works for you.

OpenStudy (anonymous):

For output, maybe you are looking for the newline character? "\n" print works different in 2.x as opposed to 3.x as well.

OpenStudy (anonymous):

I’m a newbie but I think you can handle long lines of code in either of two ways. Given how Python uses white space you can just break your code over more than one line. Or you can use a back slash. Example: spam = “porkstuff” + “beefstuff” + “red dye” + “mysterious chemical” + “filler” + “assorted other stuff” could be typed as: spam = “porkstuff” + “beefstuff” + “red dye” + “mysterious chemical” + “filler” + “assorted other stuff” Or as spam = “porkstuff” + “beefstuff” + “red dye” + \ “mysterious chemical” + “filler” + \ “assorted other stuff”

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!