Dictphone Lst Lstappend Type Lstappend Name Lstappend Manufacturer Lstappend Year Manufact Q37155809

dict_phone = {}
lst = []
lst.append(‘Type:’)
lst.append(‘Name:’)
lst.append(‘Manufacturer:’)
lst.append(‘Year of Manufacture:’)
lst.append(‘Place of Manufacture:’)
lst.append(‘Price:’)
lst.append(‘Success:’)

def takeRecords(fName):
   dict_phone = {}
   file = open(fName,’r’)
   for line in file:
       lst = [x.strip() for x inline.rstrip().split(“,”)]
       dict_phone[lst[0]] = lst[1:]
   file.close()

   return dict_phone

def printPopular(dict_ph):
   for type in dict_ph:
       if ‘Popular’ indict_ph[type]:
           print(lst[0] +type)
           for i inrange(0, len(dict_ph[type])):
              print(lst[i+1] + dict_ph[type][i])
       print()
             
def main():
   dict_phone = takeRecords(“data2.txt”)
   what_to_do = ‘0’
   while what_to_do.lower() != ‘quit’:
       what_to_do = input()
       if what_to_do == ‘1’:
          printPopular(dict_phone)
       else:
           print(‘EnterCorrect Input.’)
   return

if __name__ == ‘__main__’:
   main()

TXT file :

1, Note 7, Samsung,

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.