fb pixel

tuple from list

We can “freeze lists” by turning them into tuples:
greetings = ['Hi', 'Hello', 'Hey']
greetings = tuple(greetings)
print(greetings)     # ('Hi', 'Hello', 'Hey')
Note that the output of this code is ('Hi', 'Hello', 'Hey') indicating that the variable greetings is of type tuple.
We will cover tuples again when we start writing functions.

Challenge

Given n names in the input, create a tuple called names and print the resulting tuple in the output.
The first line of the input contains a single integer n. The next n lines contain names each on a separate line.
The program should print a single line - the resulting tuple.
Input
5
Anna
Bella
Lucy
Stella
Susan

Output
('Anna', 'Bella', 'Lucy', 'Stella', 'Susan')
 
To check your solution you need to sign in
Sign in to continue