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 them I have to use one print()
statement for all this and I need to format it so that each piece of information is on a different line.
What I want for the format:
first_name, last_name
course_id, course_name, email
school
But what I get is
first_name, last_name
course_id, course_name, email
school
How do I remove the space?
My code is as follows:
first_name = 'Daniel'
last_name = 'Rust'
course_id = 'Csci 160'
course_name = 'Computer Science 160'
email = '[email protected]'
school= 'Red River Highschool'
#variables printed for B
print(first_name, last_name, '\n', course_id, course_name, email, '\n', school, '\n')
print
inserts a space between each argument. You can disable this by adding , sep=''
after the last '\n'
, but then there won't be any spaces between first_name
and last_name
or between course_id
and course_name
, etc. You could then go on to insert , ' '
manually where you need it in the print
statement, but by that point it might be simpler to just give print
a single argument formed by concatenating the strings together with explicit spaces:
print(first_name + ' ' + last_name + '\n' + course_id + ' ' + course_name
+ ' ' email + '\n' + school + '\n')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With