Level 08: files and exceptions 0 van 9 activiteiten opgelost
  1. 1. Saving data Nog niet opgelost
  2. 2. School club Nog niet opgelost
  3. 3. Shopping list Nog niet opgelost
  4. 4. Attributes Nog niet opgelost
  5. 5. Cookies Nog niet opgelost
  6. 6. Morse code Nog niet opgelost
  7. 7. ini file Nog niet opgelost
  8. 8. Amino acids Nog niet opgelost
  9. 9. Gamertag Nog niet opgelost
Volgende reeks Level 09: two-dimension arrays and lists
Level 08: files and exceptions

2. School club

Meld je aan om je oplossing in te dienen en feedback te krijgen.

# School club program # ------------------------- # Subprograms # ------------------------- def add_student(): student = input("Enter your name to sign up for the club: ") student = student + "\n" file = open("programming.txt", "a") file.write (student) file.close() print("You have been signed up", student) def show_students(): print("Students that signed up for the programming club:") file = open("programming.txt", "r") for student in file: student = student.strip() print(student) file.close() def menu(): print("1. Sign up") print("2. Show students") choice = "" while choice not in ["1", "2"]: choice = input("Enter choice: ") match choice: case "1": add_student() case "2": show_students() # ------------------------- # Main program # ------------------------- menu()