Python Forum
Need help with defining messages and player guesses in a lottery
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help with defining messages and player guesses in a lottery
#1
Hello, I'm experimenting with the definition function and have stumbled upon a problem which I do not know how to make it work.
I'm making a very simple lottery, the lottery_draws code works perfectly, however I'm trying to gain a better understanding of how the def functions work aswell as creating a guess system, depending on how many guesses you got right out of 5, it will print

I'm struggling with how to code the "Player guesses"
And when I print "message" nothing appears (I wrote this when message1 and message" only contained "text here" (so it didn't have "text here" + lottery_draws)

import random

### Lottery Draws List ###
lottery_draws = []

### Actual Random Lottery Draws ###
for i in range(0, 5):
    number = random.randint(1, 20)
    while number in lottery_draws:
        number = random.randint(1, 20)
    lottery_draws.append(number)

### Player Guesses ###

print('Take a 5 guesses, between 1-20')
guesses = input('')
    if guesses in lottery_draws:
        return("Congratulations, you got X guesses right")
    elif guesses in lottery_draws: # Is equal to "1"
        return("Congratulations, you got 1 guess right")
    else:
        return("Too bad, you didn't get a single guess right")

### The Finale ###
def message():
    message1 = "Today's lottery draws are: " + lottery_draws
    message2 = # "\nYou got X guesses right."
    return(message1 + message2)

message
Reply


Messages In This Thread
Need help with defining messages and player guesses in a lottery - by Kanashi - Nov-23-2019, 02:43 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Lottery generator (beginner) Hullari 3 7,164 Jul-03-2019, 04:46 PM
Last Post: perfringo
  logging messages ahead of print messages vindo 6 3,260 Jun-18-2019, 02:45 PM
Last Post: vindo
  [split] Lottery System on my mobile website sibt007 1 2,472 Sep-27-2018, 12:56 AM
Last Post: micseydel
  Lottery System on my mobile website nooxm123 1 2,643 Feb-06-2018, 10:55 AM
Last Post: j.crater

Forum Jump:

User Panel Messages

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