Python Forum

Full Version: switch case not working
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am trying to read a file using a switch case and an input.




while True:
  choice = input("(1) Write A File\n(2) Read A File\n(3) Append A File\n\n")
  match choice:
    case 1:
      pass
    case 2:
      file_name = input("Enter The File Name: ")
      file_name = open(file_name, "r")
      print(file_name)
      file_name.close()
    case 3:
      pass
input returns str, you try to match int