Ask coding questions

← Back to all posts
Python: How do I do this??
Kavin1983 (1)

Whenever I type in a student name it just doesn't print out anything at all even though I know the student is in the list, any help?


you might want to try using a for loop to loop over your names. and getting it from there.

MatthewMartin14 (0)

when ever you print(class_students) you get {<main.Students object at 0x7f204b5b0850>, <main.Students object at 0x7f2042f47cd0>, <main.Students object at 0x7f2042f47d00>, <main.Students object at 0x7f204b5b05b0>, <main.Students object at 0x7f2042f47dc0>} witch they way you asking for the inputs wont equal the variables in that list

InvisibleOne (2677)

The issue is that the student is a string, and you are checking to see if that string is equal to a class object, which it of course isn't. What you really should do, is something like this:

student = input().title()
for s in class_students:
  if == student:
IntellectualGuy (662)

It's your line 21 that has some errors, do this instead class_students = {'Kavin', 'Bob', 'Will', 'Joe', 'Jack'} or class_students = {,,,,}

19ecal (228)

I guess this is because the set class_students is a set of Students objects (not strings). Maybe try making it {,} etc.