I'm trying to get the user input value from the function (enter_student_name) and add it into my dictionary function (add_student). But when I print, I get a Boolean value instead of the string that was entered.
Console Example: Enter student name: john
[{'name': True}]
I want it to return [{'name': john}] instead.
students = []
def enter_student_name():
while True:
student_name = str.isalpha(input('Enter student name: '))
if student_name:
add_student(student_name)
print(students)
# enter_student_id()
else:
print('Please enter a name only')
continue
def add_student(name):
student = {"name": name }
students.append(student)
ifhas absolutely nothing to do with it, its the.isalpha()that's turning your string into a boolean.