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")
Python

Comments

Popular posts from this blog

Quotation marks to wrap an element in HTML

Making GUI Calculator in Tkinter Python

Create Basic "Search Engine" in Python