Stuck on Exercise 12.5 #2
Replies: 1 comment
-
Hi @coutinholfc , please check the message I left in the another discussion. Have a nice day! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everyone!
Hope I am in the right section to ask my question.
The code I made as a solution for the exercise E12.5 wasn't enough as it was only printing the last team name and country I was typing by keyboard, but as I moved forward in the book I learned that variable of the type list and dict store references which made sense to the result i was getting
If possible I would request the proper solution
Here is the result i would get if I enter the same input example:
[{'name':'PSG','country':'France'},{'name':'PSG','country':'France'}]
instead of:
[{'name':'Real Madrid','country':'Spain'},{'name':'PSG','country':'France'}]
Here is the code
Thank you
NumberofTeams=int(input("Enter the number of the teams you like:"))
i=0
list1={}
list2=[]
while i<NumberofTeams:
name=input("Enter the name of the team:")
list1["name"]=name
country=input("Enter the country of the team:")
list1["country"]=country
list2.append(list1)
i=i+1
print(list2)
Beta Was this translation helpful? Give feedback.
All reactions