Question

Alice travels a lot for her work. Each time she travels, she visits a single city...

Alice travels a lot for her work. Each time she travels, she visits a single city before returning home.

Someone recently asked her “how many different cities have you visited for work?” Thankfully Alice has kept a log of her trips. Help Alice figure out the number of cities she has visited at least once.

Homework Answers

Answer #1

This problem can be solved in a number of ways. The simplest way to solve it is-

1. Take input as how many cities have been visited irrespective of number of times visited

2. Input the names of cities

3. Store the cities in a list only if it is unique

4. Print the length of the list

Python Code-

#input the number times trip taken
n=int(input())

#a list for storing unique cities

list = []

#if name of city is not in the list already, add it to the list

for i in range(n):
   city= input()
   if city not in list:
      list.append(city)

#print the length of the list i.e number or cities visited atleast once

print(len(list))

You can also find the names of cities by printing the list itself using "print(list)" at the end.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
You are the RN on a morning shift on the respiratory ward of a large inner-city...
You are the RN on a morning shift on the respiratory ward of a large inner-city hospital. At 10:30 AM you receive a patient from the Emergency Department. This is the hand-over you receive. I My name is Catriona and I am the A&E RN who has been caring for Ms Aaliyah Abimbola. Thank you so much for taking this patient so quickly. We’re so busy we haven’t time to do much for her apart from get her ready to...
Reba Dixon is a fifth-grade school teacher who earned a salary of $38,000 in 2018. She...
Reba Dixon is a fifth-grade school teacher who earned a salary of $38,000 in 2018. She is 45 years old and has been divorced for four years. She receives $1,200 of alimony payments each month from her former husband (divorced in 2016). Reba also rents out a small apartment building. This year Reba received $50,000 of rental payments from tenants and she incurred $19,500 of expenses associated with the rental. Reba and her daughter Heather (20 years old at the...
Case Study Felicia Jones is a 25-year-old pregnant woman. She is married to Barry, a salesman...
Case Study Felicia Jones is a 25-year-old pregnant woman. She is married to Barry, a salesman at a new car dealership. This is her third pregnancy. Her first two pregnancies were uncomplicated, resulting in normal spontaneous vaginal deliveries at 39 and 40 weeks’ gestation. She recuperated well from her first two deliveries, and both mother and baby were discharged home in the usual 3 days. Mrs. Jones has not been employed outside the home since her first pregnancy. She devotes...
To complete each assignment, you will need to read the case study. Assume that the client...
To complete each assignment, you will need to read the case study. Assume that the client described in each case study meets criteria for a DSM-5 disorder. You will then consult the DSM-5 criteria and write 1-2 detailed paragraphs in which you assign a primary diagnosis for the client and justify that diagnosis. In this section you should reference EACH of the DSM-5 criteria for the diagnosis you are assigning and provide evidence from the case study for or against...
PART 2 CASE ETHICAL CHOICES IN EMPLOYEE DISCOUNTS Angela is feeling a lot of stress at...
PART 2 CASE ETHICAL CHOICES IN EMPLOYEE DISCOUNTS Angela is feeling a lot of stress at work these days and she’s worried that her behaviour over the past few months will get her into trouble, not only with her boss and the company she works for, but also potentially with the police. It all started a few months ago, when one of Angela’s old classmates came in to the store where she worked. Her classmate explained that she was just...
1. Entrepreneurship: Urban Escape case study Watch the video in which Maia Josebachvili and Bram Levy...
1. Entrepreneurship: Urban Escape case study Watch the video in which Maia Josebachvili and Bram Levy discuss starting Urban Escapes, which has since been bought by LivingSocial. Then use your knowledge of entrepreneurship to answer the questions. Video Script: >> So my dad once told me that the recipe for success is hard work, intelligence, and luck. I'm Maia, founder of Urban Escapes, and now National Director of Living Social Escapes. So after college I actually did the thing that...
Read "Case Study on Jose and Carmen, located at the beginning of Chapter 11. Review the...
Read "Case Study on Jose and Carmen, located at the beginning of Chapter 11. Review the Chicano/Latino Model of Ethnic Identity in Chapter 11. Which of the assumptions from the Chicano/Latino Model of Ethnic Identify do you think are applicable to Jose and Carmen and why? José is a 13-year-old student referred to his school counselor, Jillian, by his math teacher, Mr. Justice. Mr. Justice reports that José appears disinterested in his class assignments and fails to complete his homework...
Powerpoint slides for COPD with the given case study by using CRC. Ms Aaliyah Abimbola Background...
Powerpoint slides for COPD with the given case study by using CRC. Ms Aaliyah Abimbola Background information for the assignment. You are the RN on a morning shift on the respiratory ward of a large inner-city hospital. At 10:30 AM you receive a patient from the Emergency Department. This is the hand-over you receive. I My name is Catriona and I am the A&E RN who has been caring for Ms Aaliyah Abimbola. Thank you so much for taking this...
Ms Aaliyah Abimbola Background information for the assignment. You are the RN on a morning shift...
Ms Aaliyah Abimbola Background information for the assignment. You are the RN on a morning shift on the respiratory ward of a large inner-city hospital. At 10:30 AM you receive a patient from the Emergency Department. This is the hand-over you receive. I My name is Catriona and I am the A&E RN who has been caring for Ms Aaliyah Abimbola. Thank you so much for taking this patient so quickly. We’re so busy we haven’t time to do much...
Powerpoint slides for COPD with the given case study by using CRC. Ms Aaliyah Abimbola Background...
Powerpoint slides for COPD with the given case study by using CRC. Ms Aaliyah Abimbola Background information for the assignment. You are the RN on a morning shift on the respiratory ward of a large inner-city hospital. At 10:30 AM you receive a patient from the Emergency Department. This is the hand-over you receive. I My name is Catriona and I am the A&E RN who has been caring for Ms Aaliyah Abimbola. Thank you so much for taking this...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT