How many sweets in the jar? Python Challenge (2024)

How many sweets in the jar? Python Challenge (1)“Guess how many sweets are in the jar” is a fundraising game. A large see-through jar is filled with a carefully counted number of sweets. People then try to guess how many sweets are in the jar. Each contestant has to donate a small amount of money to have a go. Guesses are recorded (name + guess). At the end of the game, the nearest guesser wins the content of the jar.

In this challenge we are using a Python script to record the names and guesses (number of sweets) of each contestant. We record this information in a list of lists called guesses.

Your challenge is to complete this code from line 63 to scan through all the guesses from this list and find out who has the nearest guess!

How many sweets in the jar? Python Challenge (2)

Solution...

The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area

Tagged with: iteration, List

How many sweets in the jar? Python Challenge (2024)
Top Articles
Latest Posts
Article information

Author: Stevie Stamm

Last Updated:

Views: 6142

Rating: 5 / 5 (80 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Stevie Stamm

Birthday: 1996-06-22

Address: Apt. 419 4200 Sipes Estate, East Delmerview, WY 05617

Phone: +342332224300

Job: Future Advertising Analyst

Hobby: Leather crafting, Puzzles, Leather crafting, scrapbook, Urban exploration, Cabaret, Skateboarding

Introduction: My name is Stevie Stamm, I am a colorful, sparkling, splendid, vast, open, hilarious, tender person who loves writing and wants to share my knowledge and understanding with you.