Question: i need this solve urgent Question-2: Write a Python program that will take your Student ID as an input and print a dictionary, where the

 i need this solve urgent Question-2: Write a Python program that

i need this solve urgent

Question-2: Write a Python program that will take your Student ID as an input and print a dictionary, where the keys will be the unique digits from your given Student ID and the value will be a list of tuples according to the following. Here, every tuple will hold two indices, where the first index will hold the index of that digit's Nth occurrence in the given Student ID and the second index will hold the number of occurrences thus far or the Nth value. ============ Sample Input 1: 17301106 Sample Output 1: {1: [(0, 1), (4,2), (5, 3)], 7: [(1, 1)], 3: [(2, 1)], 0: [(3, 1), (6, 2)], 6: [(7,1)]} Explanation 1: Here, in the given Student ID, unique digits are: 1,7,3, 0 and 6. So, the keys will be 1, 7, 3,0 and 6. Moving forward, in the given Student ID, 1 is in 0,4 and 5 indices, therefore for the three occurrences, there will be a list of three tuples as a value for the key 1. So, the value will be [(Index: 0, Occurrence: 1), (Index: 4, Occurrence: 2), (Index: 5, Occurrence: 3)] and so on similarly for the keys 7,3,0 and 6. ============ ======== ===== Sample Input 2: 21166055 Sample Output 2: {2:[(0, 1)], 1: [(1, 1), (2, 2)), 6: [(3, 1), (4, 2)], 0: [(5, 1)], 5: [(6, 1), (7,2)]} Explanation 2: Here, in the given Student ID, unique digits are: 2, 1,6, 0 and 5. So, the keys will be 2, 1, 6, 0 and 5. Furthermore, in the given Student ID, 2 has occurred in only index 0, therefore for the only occurrence, there will be a list of one tuple as a value for the key 2. So, the value will be [(Index: 0, Occurrence: 1)] and so on and so forth for the rest of the unique digit keys

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!