Collect value from a dictionary

Asked

Viewed 16 times

1

I’m in a project where inside the dictionary the key is a person name and its value is list. The list has values filled in as shown in the example: Ana:(3,5) - "Ana" is the key of the dicio and "3,5" is the value of the list created and assigned in the dicio. I want to collect this value "3,5", already tried to use get but it returns me "None" Code: nota2 = aluno.get("{}".format(aluno)) In this case, the variable "nota2" should be 3.5. The value of the list will always vary. I hope I was clear enough, thank you!

  • Dude you’re passing a tuple as "Ana" value, try {"Ana":3.5}

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.