Alguien me puede decir como resolver este ejercicio he estado tratando pero no puedo ni siquiera se con que función podría resol | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Alguien me puede decir como resolver este ejercicio he estado tratando pero no puedo ni siquiera se con que función podría resol

contacts = [ ('James', 42), ('Amy', 24), ('John', 31), ('Amanda', 63), ('Bob', 18) ] #el ejercicio pide que reciba una cadena como entrada e imprima la edad del contacto que tomo como entrada: Ejemplo: Entrada: Amanda Salida: Amanda is 63

10th Jan 2022, 4:01 PM
Alejandro Medrano
5 Answers
+ 4
Puedes resolverlo muy facilamente. print(dict(contacts)['Amanda']) Pero no creo que gusta el profesor.
10th Jan 2022, 4:42 PM
Oma Falk
Oma Falk - avatar
+ 3
Cristian Gabriel Mazzulla My spanish is lousy... I think, it is not the expected solution in classes. It might be yours just to learn iterating through tuples. But it is sexy....isn't it?
10th Jan 2022, 4:51 PM
Oma Falk
Oma Falk - avatar
+ 2
Supongo que tendrás que iterar por los valores de contacts evaluando cada string, no se me ocurre una mejor opción...🤔
10th Jan 2022, 4:29 PM
CGM
CGM - avatar
+ 2
Ah well, now I do understand, Yeah it's "sexy"😂
10th Jan 2022, 4:56 PM
CGM
CGM - avatar
0
Oma Falk ah, esa opción me gusta mas (no entiendo lo último que decis jaja)
10th Jan 2022, 4:44 PM
CGM
CGM - avatar