In Python please.
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.
Input:
The first line of input contains a single positive integer T <_ 50 indicating the number of test cases. The first line of each test case also contains a single positive integer n indicating the number of work trips Alice has taken so far. The following n lines describe these trips. The ith such line simply contains the name of the city Alice visited on her i th trip.
Alice's work only sends her to cities with simple names: city names only contain lowercase letters, have at least one letter, and do not contain spaces.
The number of trips is at most 100 and no city name contains more than 20 characters.
Output:
For each test case, simply output a single line containing a single integer that is the number of distinct cities that Alice has visited on her work trips.

Respuesta :

Answer:

Explanation:

We have the following

t is the number of test cases.

n is the number of trips for each testcase

name is the name of the city

all the unique names are added to the list and at last the length of the list is printed.

The program is written as follows

t = int(input) - for i in range(t): n = int(input) 1 = [] for j in range(n): name = input if name not in l: 1.append(name) pr

t = int(input())

for i in range(t):

n = int(input())

l = []

for j in range(n):

name = input()

if name not in l:

l.append(name)

 

print(len(l))

Output:

Ver imagen yahayadanjuma55

The program illustrates the use of lists.

Lists in Python are used to store several values on one variable.

The program written in Python where comments are used to explain each line is as follows

#This gets input for the number of test cases

T = int(input())

#This iterates through the test cases

for i in range(T):

   #This gets input for n; the number of work trips

   n = int(input())

   #This creates a list of the cities visited

   city = []

   #This iterates through the work trips

   for j in range(n):

       #This gets the name of the city

       name = input()

       #For names not in the list of city

       if name not in city:

           #The city is appended to the city list

           city.append(name)

#This prints the number of cities

print(len(city))

Read more about Python lists at:

https://brainly.com/question/24941798