Member-only story
Python 3: How to Write a Program That Allows the Prediction of a Lucky Fruit
This simple luck game lets the user pick a lucky fruit from a list, and guess its corresponding number. The user is given 3 attempts.
In this article, write a program that allows the prediction of a lucky fruit.
Requirements: Have a basic understanding of programming in regards to arrays, loops, if statements, and data types.
You can download the current version of Python (3.12.3): Here.
(https://www.python.org/downloads/)
You can download the current version of Python (3.12.3) with the link below.
(https://www.python.org/downloads/)
The page provides the packages for the operating systems: Windows, Linux, MacOS, etc.
Logic Behind the Lucky Fruit Game
A list containing 6 lucky fruits is created, with a counter to determine the number of tries. The user is prompted to enter a lucky fruit. A corresponding number is then requested. Based on both the fruit and the number entered by the user; the program finds the matching fruit within the “LuckyFruit” list.