Menu

4 12 Points Write Program First Repeatedly Ask User Short String Appended List User Enters Q43839456

4. 12 points Write a program to first repeatedly ask the user for a short string which is appended to a list, then after the

PYTHON
need help with this question
thanks in advance

4. 12 points Write a program to first repeatedly ask the user for a short string which is appended to a list, then after the user enters <CR>, again repeatedly ask the user for a string, which this time is added to a tuple. Once the user enters <CR>, the program should display: a) the list and the tuple of user’s strings b) All the strings that appear in both collections – the list and the tupple c) Number of the strings that appear in both collections Hint: a tuple containing a single element a, is coded as (a,) not as (a) A typical run might look like: adding to a list please enter a short string or <CR> to terminate aaa please enter a short string or <CR> to terminate abc please enter a short string or <CR> to terminate bbb please enter a short string or <CR> to terminate bcd please enter a short string or <CR> to terminate ccc please enter a short string or <CR> to terminate cde please enter a short string or <CR> to terminate now adding to a tuple please enter a short string or <CR> to terminate abc please enter a short string or <CR> to terminate cde please enter a short string or <CR> to terminate fgh please enter a short string or <CR> to terminate your list: [‘aaa’, ‘ab’, ‘bbb’, ‘bcd’, ‘ccc’, ‘cde’] your tuple: (‘abc’, ‘cde’, ‘fgh’) string abc is in both list and tuple string cde is in both list and tuple 2 strings are in both Show transcribed image text 4. 12 points Write a program to first repeatedly ask the user for a short string which is appended to a list, then after the user enters , again repeatedly ask the user for a string, which this time is added to a tuple. Once the user enters , the program should display: a) the list and the tuple of user’s strings b) All the strings that appear in both collections – the list and the tupple c) Number of the strings that appear in both collections Hint: a tuple containing a single element a, is coded as (a,) not as (a) A typical run might look like: adding to a list please enter a short string or to terminate aaa please enter a short string or to terminate abc please enter a short string or to terminate bbb please enter a short string or to terminate bcd please enter a short string or to terminate ccc please enter a short string or to terminate cde please enter a short string or to terminate now adding to a tuple please enter a short string or to terminate abc please enter a short string or to terminate cde please enter a short string or to terminate fgh please enter a short string or to terminate your list: [‘aaa’, ‘ab’, ‘bbb’, ‘bcd’, ‘ccc’, ‘cde’] your tuple: (‘abc’, ‘cde’, ‘fgh’) string abc is in both list and tuple string cde is in both list and tuple 2 strings are in both

Expert Answer


Answer to 4. 12 points Write a program to first repeatedly ask the user for a short string which is appended to a list, then after…

OR