Match Case Statements in Python


   print("\nThe capital of the following countries can be known.\nPakistan\nIndia\nTurkey\nIran\n")
cName = input("Plz enter country name: ")

match cName:
    case "Pakistan":
        print("The capital is Islamabad.\n")
    case "India":
        print("The capital is New Delhi.\n")
    case "Turkey":
        print("The capital is Ankara.\n")
    case "Iran":
        print("The capital is Tehran.\n")
    case _: #default case
        print("Sorry! This country is not in our database.\n")

    

Comments

Popular posts from this blog

Quotation marks to wrap an element in HTML

What is the difference between iostream and iostream.h in cpp?

The Basic Structure of a Full-Stack Web App