Question: Python programming Problem 1. Tuple Input a) Write a function called input tuple (in a new file p1.py) that reads from the terminal a sequence
Python programming



Problem 1. Tuple Input a) Write a function called input tuple (in a new file p1.py) that reads from the terminal a sequence of objects with types provided by a tuple given as parameter and that returns the sequence of objects read as a tuple The function will iterate through the types tuple and will try to parse the input string based on the types The function takes the following parameters: prompt: a string to be displayed as input prompt * types: a tuple of type objects that must match the types of the data entered by the user and returned by the function. The only types supported are int, float, str, bool sep: a string that separates the input objects, with default value ,". . The function returns one of: .if parsing the data from the user according to the types tuple succeeds, then it returns the tuple with the converted data to Python objects, if parsing the data from the user according to the types tuple fails, then it returns the empty tuple () Error handling: the function must not raise/throw errors related to parsing Use proper error handling with try/except. In case of any error, print an error message to the terminal and return the empty tuple 0 or input/read operations
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
