Python Forum
Powerball assignment, how to get correct output of a dictionary ?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Powerball assignment, how to get correct output of a dictionary ?
#2
matches = (white_nums, red_nums)
creates a tuple that wont match with the keys in the dictionary that are strings.
change this to
matches = f'{white_nums}, {red_nums}'
 for matches in Prizes:
     print(Prizes[matches])
is just looping through the whole dictionary and overwrites the previous assignment to matches
remove those lines and replace with
result = Prizes.get(matches, 'sorry no prize this time')
print(result)
this will grab the value if the key matches exists or return the the string i gave as a default.

Also note there is an error in the size of your range
for x in range(0, 4):
its not using all the expected input values.
Reply


Messages In This Thread
RE: Powerball assignment, how to get correct output of a dictionary ? - by Yoriz - Mar-19-2019, 10:33 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  to find in dictionary given parameter 'name' and to output position Liki 10 1,531 Oct-08-2023, 06:38 AM
Last Post: Pedroski55
  dictionary output to text file (beginner) Delg_Dankil 2 1,295 Jul-12-2023, 11:45 AM
Last Post: deanhystad
  Powerball List jackthechampion 1 2,533 Apr-13-2020, 06:02 PM
Last Post: deanhystad
  Dictionary based assignment: Need help RoyceJ 6 3,966 Aug-29-2018, 05:30 AM
Last Post: perfringo
  Powerball script help nick 6 7,172 Nov-11-2016, 07:56 PM
Last Post: micseydel
  PowerBall Help nick 3 4,860 Nov-11-2016, 06:59 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020