As you'll see, I'm VERY new to programming and Python. I'm trying to write a simple function to get the number of students in a class from the user, and then ask for a student name which will iterate and populate an empty list. I though this would work because the condition would check to see if the length of the list is equal to the class size and keep running until it is, but that isn't the case. Instead, I get this error:
"line 5, in setupclass_
_ if len(students) < class_size:_
TypeError: '<' not supported between instances of 'int' and 'str'"
when I used a variable like this to check length L = len(students) and printed L, I got an integer, and when I printed out class_size, I would get whatever the input number was, so I thought I was checking a number against a number so I'm confused by the "int and 'str" error.
Here is the code:
def setup_class(): students =  class_size = input("how many students in class?: ") if len(students) < class_size: student_names = input("Enter student name and press Enter: ") students.append(student_names) print(students) setup_class()