I have a question. In a assignment it asks for me to do the following below...
if "peek" then print the Student object at the beginning
of the list (using __str__) but don't remove it from
the list;
Could you explain what it means?
This is what I have so far,
elif ask == "peek":
print("First Name In List =", names[0])
How would you make it a string?
I know have a example of it but I'm not sure how to apply it to my code...The
example is below.
def __str__(self):
return self.sides + "\t" + self.value
Also below is part of the assignment and my whole code is in the attachment.
A "main" function which does the following:
(1) create an empty list;
(2) ask the user if he/she wants to perform a list operation.
if "yes":
(a) prompt the user for the operation:
"test", "peek", "add", or "remove";
(b) perform the operation:
(i) if "test" then print whether the list is empty or not;
(ii) if "peek" then print the Student object at the beginning
of the list (using __str__) but don't remove it from
the list;
(iii) if "add", then prompt the user for student info, make
a Student object containing that info, and
add that Student object to the end of the list;
(iv) if "remove", then delete the Student object at the
beginning of the list and print it using __str__;
repeat step (2) until the user enters "no";
(3) neatly print the entire list from beginning to end.
StudentTester.py
Description: StudentTester.py
_______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
