Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Output list data in one line

the problem is that i cannot output all the data in one line, lettergrade(float(mylist[2])) and even a simple string like "hello" is always on the next line

lettergrade is just a simple function that returns a string

print("Student Name\t\tFinal Grade\t\tLetter Grade")
mylist = indata.split(",")
print(mylist[0] + " " + mylist[1] + "\t\t" + mylist[2] + "\t\t" + lettergrade(float(mylist[2])))

mylist looks like

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

['Johnson', 'Abby', '95.6\n']
['Smith', 'Frank', '91.3\n']
['Carson', 'Jack', '89.1\n']
['Wells', 'Orson', '87.9\n']

Output I get

Student Name            Final Grade             Letter Grade
Johnson Abby            95.6
                A
Smith Frank             91.3
                A
Carson Jack             89.1
                B

Expected output

Student Name            Final Grade             Letter Grade
Johnson Abby            95.6                    A
Smith Frank             91.3                    A           
Carson Jack             89.1                    B

>Solution :

\n stands for a line break, you should remove it:

mylist = indata.replace('\n', '').split(",")
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading