Print multiple lines in one statement without leading spaces

后端 未结 6 1450
有刺的猬
有刺的猬 2021-01-13 03:00

So for my first project it is a simple program that prints your name class you are in and what high school you went to. The one thing that is messing me up is for one of the

6条回答
  •  无人及你
    2021-01-13 03:27

    I recommend reading through str.format() to print your information.

    The spaces in your output come from the fact that you've called the print function, passing a list of strings, instead of passing the print function a single string.

    print(first_name + ' ' + last_name + '\n' + course_id + ' ' + course_name + ' ' + email + '\n' + school)
    

    yields

    Daniel Rust
    Csci 160 Computer Science 160 blah@gmail.com
    Red River Highschool
    

提交回复
热议问题