0

Here is my code


print("Type the name of the country to reveal its data")


name = input()

Usa = """Total Cases : 739,502
Total Recovered : 68,442
Total Deaths : 39,040""" 

France = """Total Cases : 151,793 
Total Recovered : 35,983
Total Deaths : 19,323   """

Germany = """Total Cases : 144,033
Total Recovered : 88,000     
Total Deaths : 4,545"""

India = """Total Cases : 16,365 
Total Recovered : 2,466 
Total Deaths : 521"""

Italy = """Total Cases : 175,925    
Total Recovered : 44,927    
Total Deaths : 23,227"""

if name == "Usa".lower() or name == "Usa".upper( ) or name == "Usa".title() :
    print(Usa)
elif name == "Germany".lower() or name == "Germany".upper() or name == "Germany".title() :
    print(Germany)
elif name == "Italy".lower() or "Italy".upper() or "Italy".title() :
    print(Italy)
elif name == "India".lower() or "India".upper() or "India".title() :
    print(India)

So what i want here is that i want the code to ask the user to input the country name again after it has displayed the data of the country's name entered before I have to run my code again and again to get different countries data

2 Answers2

0

Try this :

Usa = """Total Cases : 739,502
Total Recovered : 68,442
Total Deaths : 39,040""" 

France = """Total Cases : 151,793 
Total Recovered : 35,983
Total Deaths : 19,323   """

Germany = """Total Cases : 144,033
Total Recovered : 88,000     
Total Deaths : 4,545"""

India = """Total Cases : 16,365 
Total Recovered : 2,466 
Total Deaths : 521"""

Italy = """Total Cases : 175,925    
Total Recovered : 44,927    
Total Deaths : 23,227"""


name = input("Type the name of the country to reveal its data , Type 'Done' to stop" ).lower()
while name != "done" :
    if name == "usa" :
        print(Usa)
    elif name == "germany" :
        print(Germany)
    elif name == "italy" :
        print(Italy)
    elif name == "india" :
        print(India)
    name = input("Type the name of the country to reveal its data , Type 'Done' to stop" ).lower()
AmirHmZ
  • 516
  • 3
  • 22
0

You will need to use a loop. It will continue to answer as long as user inputs valid country.

Usa = """Total Cases : 739,502
    Total Recovered : 68,442
    Total Deaths : 39,040""" 

    France = """Total Cases : 151,793 
    Total Recovered : 35,983
    Total Deaths : 19,323   """

    Germany = """Total Cases : 144,033
    Total Recovered : 88,000     
    Total Deaths : 4,545"""

    India = """Total Cases : 16,365 
    Total Recovered : 2,466 
    Total Deaths : 521"""

    Italy = """Total Cases : 175,925    
    Total Recovered : 44,927    
    Total Deaths : 23,227"""
while True:
    print("Type the name of the country to reveal its data")
    name = input()
    if name == "Usa".lower() or name == "Usa".upper( ) or name == "Usa".title() :
        print(Usa)
    elif name == "Germany".lower() or name == "Germany".upper() or name == "Germany".title() :
        print(Germany)
    elif name == "Italy".lower() or "Italy".upper() or "Italy".title() :
        print(Italy)
    elif name == "India".lower() or "India".upper() or "India".title() :
        print(India)
    else:
        print("bye")
        break
mahoriR
  • 4,377
  • 3
  • 18
  • 27