Newline (NuBe Question)

dn PythonList at DancesWithMice.info
Wed Nov 15 04:19:41 EST 2023


On 15/11/2023 20.25, Grizzy Adams via Python-list wrote:
> Hi & thanks for patience with what could be simple to you
> 
> Have this (from an online "classes" tutorial)

There are lots of on-line classes!


> --- Start Code Snippit  ---
> 
> students = []
> grades = []
> for s in geographyClass:
> 	students.append(geographyStudent(s))
> for s in students:
>                  grades.append(s.school)
>                  grades.append(s.name)
>                  grades.append(s.finalGrade())
>                  if s.finalGrade()>82:
>                          grades.append("Pass")
>                  else:
>                          grades.append("Fail")
> print(grades)
> 
> --- End Code Snippit  ---
> 
> I have extended (from tutorial) it a bit, I would really like to have a newline
> 
> at end of each record, I have searched (and tested) but cant get "\n" to give a
> 
> newline, I get "Mydata\n"
> 
> Do I need to replace "append" with "print", or is there a way to get the
> newline in as I append to list?

Don't know how "Mydata..." results - where is it in the code.

What do you see when grades is printed?
Do you really want data-values all mashed together?

Yes, what changed after removal of all the .append()-s, and instead, 
within the (second) for-loop print( school, name, ... ) was used?

Is it easier to go on from there?

-- 
Regards,
=dn


More information about the Python-list mailing list