127. Python Program to Convert a List into a Set and a Tuple
EasyWhich one?
Overview
Pour the same words into three containers: a list, a set and a tuple.
Problem Statement
Read one line of fruit names separated by spaces. Print the list of words, the number of different fruits, and a tuple of the different fruits in A to Z order. For example, for mango apple mango kiwi apple:
List: ['mango', 'apple', 'mango', 'kiwi', 'apple']
Different: 3
Tuple: ('apple', 'kiwi', 'mango')
Print the list and the tuple directly, the way Python shows them. A tuple with one item shows its comma: ('kiwi',).
Use input() with no prompt text: the tests type the input for you, and a prompt would end up in your output.
Input
One line of words. Example:
mango apple mango kiwi apple
Output
The output for that example:
List: ['mango', 'apple', 'mango', 'kiwi', 'apple']
Different: 3
Tuple: ('apple', 'kiwi', 'mango')
The tests try 3 different inputs.