QUESTION DATED : 30/11/2024

(Question Code : QC24113000)

  A PROGRAM THAT TAKES A TUPLE AS A INPUT, AND THEN CREATES A DICTIONARY WHERE EACH ELEMENT FROM THE TUPLE IS ASSOCIATED WITH ITS INDEX POSITION .  


      ANSWER

a = []  

b = []  

def positioning_tuple(c):

    for i in c:

        a.append(i)

    if len(a) == len(c):

        for j in a:

            b.append(a.index(j))  

c = tuple(input("Enter the tuple: ").split(','))

positioning_tuple(c)

dicts = dict(zip(a, b))

print(dicts)

                                                                      -----


No comments:

Post a Comment

APPLICATIONS

Support Us Help us create more useful apps! We've already built a screen recorder(availabe in APPS...