Quantcast

A community for students. Sign up today!

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

breeanneschill

  • one year ago

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.

  • This Question is Open
  1. JJTraylor
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

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

  2. ramc
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

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

  3. KonradZuse
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

  4. msmithhnova
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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

  5. lowsypunk
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

  6. msmithhnova
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

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

  7. hduff
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 1

    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”

  8. Not the answer you are looking for?
    Search for more explanations.

    Search OpenStudy
    • Attachments:

Ask your own question

Ask a Question
Find more explanations on OpenStudy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.