Newline (NuBe Question)
Thomas Passin
list1 at tompassin.net
Thu Nov 16 07:47:21 EST 2023
On 11/16/2023 1:19 AM, Grizzy Adams via Python-list wrote:
> Wednesday, November 15, 2023 at 15:54, Thomas Passin via Python-list wrote:
> Re: Newline (NuBe Question) (at least in part)
>
>> On 11/15/2023 2:04 PM, Grizzy Adams via Python-list wrote:
>>> Wednesday, November 15, 2023 at 12:19, Pierre Fortin wrote:
>>> Re: Newline (NuBe Question) (at least in part)
>
>>>> On Wed, 15 Nov 2023 16:51:09 -0000 Grizzy Adams via Python-list wrote:
>
>>>> I don't give solutions; just a nudge... you appear not to fully grok
>>>> "list"; your list is ONE list with no delineation between students. You
>>>> want a "list of lists"...
>
>>>>> ['Example High', 'Mary', 89.6, 'Pass', 'Example High', 'Matthew', 76.5, 'Fail', 'Example High', 'Marie', 80.4, 'Fail', 'Example High', 'Manuel', 79.6, 'Fail', 'Example High', 'Malala', 98.9, 'Pass']
>
>>>> Like this:
>
>>>> students = [
>>>> ['Example High', 'Mary', 89.6, 'Pass'],
>>>> ['Example High','Matthew', 76.5, 'Fail'],
>>>> ['Example High', 'Marie', 80.4, 'Fail'],
>>>> ['Example High', 'Manuel', 79.6, 'Fail'],
>>>> ['Example High', 'Malala', 98.9, 'Pass']
>>>> ]
>
>>> for now I made a copt of code and altered to
>>>
>>> students = []
>>> grades = []
>
>> # In this design there is no point in the extra loop.
>> # also, the indentation is wrong. Perhaps you inserted
>> # tabs? Use only spaces in these posts.
>
> I copy-pasted the code direct from IDLE, (to avoid any other typo's)
>
>> # Also you don't need the students list
>>> for student in geographyClass:
>>> # students.append(geographyStudent(s))
>> s = geographyStudent(student)
>>>
>> # for s in students:
>>> if s.finalGrade()>82: Result=("Pass")
>>> else: Result=("Fail")
>>> print(s.school, s.name, s.finalGrade(),Result)
>
> I'll hive this a try (as a learning point)
I wrote that you don't need the "students" list, which is correct. But
there could be a use for a list. It would let you change the order in
which students appear in the printed output. Knowing how to do that is
a useful skill. But that should be left for a later lesson, not mixed
in here.
More information about the Python-list
mailing list