Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env pytho
- diccionario_principal={}
- def make_albun(artista,albun,tracks=0):
- diccionario={'artista':artista ,'albun':albun,'tracks':tracks}
- return diccionario
- pos=0
- while True :
- nombre=input ("Nombre :")
- if nombre=='q':
- break
- albun=input ("Albun :")
- if albun=='q':
- break
- tracks=input ("Track :")
- if tracks=='q':
- break
- tracks =int (tracks)
- #Crea un diccionario de diccionarios
- diccionario_principal[str(pos)]=make_albun(nombre,albun,tracks)
- pos+=1
- print (diccionario_principal)
- """Pag 146 8-7. Album: Write a function called make_album() that builds a dictionary
- describing a music album. The function should take in an artist name and an
- album title, and it should return a dictionary containing these two pieces of
- information. Use the function to make three dictionaries representing different
- albums. Print each return value to show that the dictionaries are storing the
- album information correctly.
- Add an optional parameter to make_album() that allows you to store the
- number of tracks on an album. If the calling line includes a value for the num-
- ber of tracks, add that value to the album’s dictionary. Make at least one new
- function call that includes the number of tracks on an album.
- 8-8. User Albums: Start with your program from Exercise 8-7. Write a while
- loop that allows users to enter an album’s artist and title. Once you have that
- information, call make_album() with the user’s input and print the dictionary
- that’s created. Be sure to include a quit value in the while loop."""
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement