#๐Ÿ”’ elif showing syntax error?

17 messages ยท Page 1 of 1 (latest)

reef sluice
steep flumeBOT
#

@reef sluice

Python help channel opened

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.

spice rivet
#

@reef sluice show the actual code

reef sluice
rigid prism
#

The block would probably do.

reef sluice
#
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

spice rivet
#

pls ```python
code()
```

rigid prism
#

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.

reef sluice
#

i think i fixed it

#

thank you

#

should i close this thread?

rigid prism
reef sluice
#

!close

steep flumeBOT
#
Python help channel closed with !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.