#๐ elif showing syntax error?
17 messages ยท Page 1 of 1 (latest)
@reef sluice
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Closes after a period of inactivity, or when you send !close.
@reef sluice show the actual code
would you prefer the whole thing or the specific block
The block would probably do.
code()
if choice == '1':
# TODO: Get student_id and course_id from user, then call check_in().
name = input("Enter Student Name: ").strip()
enrolled_in = input("Enter courses (comma-separated): ").split(",")
enrolled_in = [course.strip() for course in enrolled_in if course.strip()]
add_student(name, None, enrolled_in)
made_change = True
elif choice == '2':
# TODO: Get student_id, then call print_student_card()
try:
student_id = int(input("Enter Student ID: "))
print_student_card(student_id)
except ValueError:
print("Invalid Student ID.")
made_change = True```
uh wait one
that indent isnt the issue it's just discord formatting
pls ```python
code()
```
This line:
enrolled_in = input("Enter courses (comma-separated): ").split(",")
is no longer indented until the if. So the if is ended. So the elif later has not if.
Sure. Type !close
!close
This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.