Trying to locate syntax error in python while loop - python

very very new beginner here - just started learning today! stumped on what the syntax error is here:
import random
x = random.randrange(7)
user_start = "yes"
user_start_input = str(input("type 'yes' to generate random number. "))
while user_start_input == user_input:
print("your random dice number is " + str(x))
user_start_input = input("roll again?")
if user_start_input != user_input:
break
print("done")
The error message is:
File "/Users/joel/Documents/Learning Python/Dice.py", line 12
while user_start_input == user_input:
^
SyntaxError: invalid syntax
what am I doing wrong?

First off we're (those that wish to answer) missing some information, while is on line 5 where as the error is being reported with while on line 12, there's plenty that could be causing an error to pop on a following line; eg. missing quote. Looks like G. Anderson already eluded to that last point, as far as errors usually being from a preceding line. My suggestion in this case would be to find an developer friendly text editor (IDE) that'll point out minor typos through syntax-highlighting; Atom is pretty groovy, especially with a few addons, but there's plenty of other text editors to play with.
Second, as commented by CoffeeTableEspresso the tabs are non-existent in your code snip! If your source code looks identical to what has been posted, then your bug-stomping has only just begun.
Third, because ya had stated that Python is not your first language it might be helpful, if not now then certainly in the future, to know of __doc__ strings, eg...
>>> print(random.randrange.__doc__)
Choose a random item from range(start, stop[, step]).
This fixes the problem with randint() which includes the
endpoint; in Python this is usually not what you want.
... many of the things within Python are documented and accessible via the __doc__ method, which can also be accessed with help(), eg. help(random.randrange), and it is possible to write your own with the following syntax...
def test_func(arg):
"""
This is a __doc__ string
"""
print("arg -> {0}".format(arg))
And finally, well for now, it's a good idea when writing in an unfamiliar language to use copious comments and split things up into smaller bits that express your intentions; for example...
#!/usr/bin/env python
import random
def dice(sides = 6):
"""
Returns random int between `1` and `sides`
"""
return random.randrange(start = 1, stop = int(sides) + 1, step = 1)
def prompt(message, expected):
"""
Returns `True` if user input matches `expected`
"""
return expected == str(input("{0} ".format(message)))
def main_loop():
"""
Returns list of `dice(...)` results, list length depends
upon number of times `prompt(...)` returns `True`
"""
roll_results = []
user_start = 'yes'
# Set message for first run of loop
message = "Type '{0}' to roll the dice".format(user_start)
while prompt(message = message, expected = user_start):
# Save dice output to variable for later use and
# append to list of rolls that will be returned
roll = dice(sides = 6)
roll_results.append(roll)
# For now just print each roll, but this is one
# aria to expand upon with your own edits
print("Rolled {0}".format(roll))
# Set new message line for following loop iterations
message = 'Roll again?'
return roll_results
# Do stuff if script is run directly instead of imported as a module
if __name__ == '__main__':
main_loop()
P.S. keep at it, eventually all the learnings'll start to click and the following RP related example classes will make more since...
#!/usr/bin/env python
from __future__ import range
import random
class DiceBag(dict):
"""
DiceBag is a collection of short-cuts to `random.randrange`.
- `selection`, list of `n` sided dice, eg `[4, 20]` would _stock_ bag with d4 and d20
"""
def __init__(self, selection = [2, 4, 20], **kwargs):
super(DiceBag, self).__init__(**kwargs)
self.update(selection = selection)
def dice(self, sides = 6):
"""
Returns random int between `1` and `sides`
"""
return random.randrange(start = 1, stop = int(sides) + 1, step = 1)
def handfull_of(self, dice = {}):
"""
Returns `dict` with lists of dice rolls
## Example
dice_bag = DiceBag()
toss_results = dice_bag.handfull_of({20: 1, 4: 2})
Should return results of one `d20` and two `d4` such as
{
20: [18],
4: [1, 3]
}
"""
output = {}
for sides, count in dice.items():
if sides not in self['selection']:
continue
rolls = []
for roll in range(count):
rolls.append(self.dice(sides))
output[sides] = rolls
if not output:
raise ValueError("No dice in bag matching sizes -> {0}".format(dice.keys()))
return output
"""
Short cuts for dice of a `n` sides, expand upon it if you wish
"""
#property
def coin(self):
return self.dice(sides = 1)
#property
def d4(self):
return self.dice(sides = 4)
#property
def d6(self):
return self.dice(sides = 6)
class Flail(DiceBag):
def __init__(self, damage_modifier = 0, damage_dice = {'sides': 6, 'count': 2}, **kwargs):
super(Flail, self).__init__(selection = [damage_dice['sides'], 20], **kwargs)
self.update(damage_modifier = damage_modifier)
self.update(damage_dice = damage_dice)
def attack(self, attack_modifier = 0):
"""
Returns `dict` with `hit` chance + `attack_modifier`
and `damage` rolls + `self['damage_modifier']`
"""
rolls = self.handfull_of(dice = {
20: 1,
self['damage_dice']['sides']: self['damage_dice']['count']
})
return {
'hit': rolls[20][0] + attack_modifier,
'damage': sum(rolls[self['damage_dice']['sides']]) + self['damage_modifier']
}
Updates
Here's what your code block may look like with proper indentation...
import random
x = random.randrange(7)
user_start = "yes"
user_start_input = input("type 'yes' to generate random number. ")
while user_start_input == user_input:
print("your random dice number is " + str(x))
user_start_input = input("roll again?")
print("done")
... and here's what a working version might look like...
import random
message = "type 'yes' to generate random number. "
expected = "yes"
while input(message) == expected:
x = random.randrange(7)
print("your random dice number is {num}".format(num = x))
message = "roll again? "
print("done")
... there's little reason to use an if something break when using while to do the same kinda thing, well given the current question's code sample.
Moving the assignment of x to be within the loop ensures that there's a chance of a new number on each iteration, while not stated I've a feeling that that was your intent.
Using input(message) and updating the message displayed instead hopefully makes sense. Though I'm not sure why you where wrapping things within str(), didn't seem to make a bit of difference when I tested.

First, it seems like you've mixed up the two variable names user_start and user_input, so those need to be changed to the same variable name.
Next, Python structures code with indentation: so the content in while loops and the like would need to be indented.
So here, you would indent all the code inside the while loop, and further indent the code inside the if statement inside the while loop.
It also seems like the purpose of your code is to simulate a dice roll each time the while loop runs again. In the while loop, you call on the variable x for the dice roll, but x is never changed. You never changed x to be a different random number, so it will just show the same random number every time the user rolls the dice again.
To fix this, simply re-define x each time the while loop is run. So just move the definition of the variable x to within the while loop.
With all these fixes, the code works:
import random
user_start = "yes"
user_start_input = str(input("type 'yes' to generate random number. "))
while user_start_input == user_start:
x = random.randrange(7)
print("your random dice number is " + str(x))
user_start_input = input("roll again?")
if user_start_input != user_start:
break
print("done")
Of course the variable names could be a bit more informative, and the code could be structured better to improve performance and user friendliness, but overall, great job for a beginner!

Related

I got stuck on this exercise can't figure the True/False part

I got some homework to do and I got stuck with this code. I have no idea how to continue.
This is what I'm suppose to do:
generate_sequence - Will generate a list of random numbers between 1 to 101. The list
length will be difficulty.
get_list_from_user - Will return a list of numbers prompted from the user. The list length
will be in the size of difficulty.
is_list_equal - A function to compare two lists if they are equal. The function will return
True / False.
play - Will call the functions above and play the game. Will return True / False if the user
lost or won.
(Sorry for copy/pasting. My English is not so good.)
import random
difficulty = 101
secret_number = 6
def generate_number():
global secret_number
secret_number = random.randint(0, difficulty)
def get_guess_from_user():
return input( "Please choose number between 1 to " + str(difficulty))
def compare_results(userInput):
isSame = False
if(secret_number == userInput):
isSame = True
return isSame
def play():
generate_number()
userInput = get_guess_from_user()
isSame = compare_results(userInput)
print("number generated is: " + str(secret_number))
print(isSame)
play()
Your "problem" is, that if(secret_number == userInput): is currently comparing an int to a str, because the result of input() is always a str, even if the input is numeric. An int and a str are never equal, thus isSame will always be False.
You have to cast the user input to int somewhere along the way before or during the comparison.
e.g.:
def get_guess_from_user():
return int(input( "Please choose number between 1 to " + str(difficulty)))
# ^^^
Otherwise, your program seems to do what you are describing.
You could save some lines of code by writing:
def compare_results(userInput):
return (secret_number == userInput)
I took the liberty to rewrite your application w/o global variables:
import random
def generate_number(difficulty):
return random.randint(1, difficulty)
def get_guess_from_user(difficulty):
return int(input( "Please choose number between 1 to {}".format(difficulty)))
def play(difficulty):
secret_number = generate_number(difficulty)
user_input = get_guess_from_user(difficulty)
is_same = (secret_number == user_input)
print("number generated is: {}".format(secret_number))
print("Your guess was {}".format( "correct :)" if is_same else "not correct :(" ))
play(5)
Note: I also changed random.randint(0, difficulty) to random.randint(1, difficulty), because the lower part is also inclusive, meaning that it could return 0. When prompting the user for a number between 1 and 5, the user might be surprised that the correct number was 0 instead.
See the docs:
random.randint(a, b)
Return a random integer N such that a <= N <= b. Alias for randrange(a, b+1).

Problem with Repeating a Function in Mastermind Game

I am designing a mastermind game to be played with python. But I encounter some problems when I try to set a function to repeat itself when the attempts are not completely correct.
My code is in two parts. For the first part it asks the user for the correct number, and then the second user tries to input his attempt number. The second part of the code breaks down his attempt into lists of numbers, and compute the number of correct integers and number of integers in correct position, then if the answer is not completely correct, the programme asks the user for a second input.
def getnumber():
predestine = input("Please input your test number")
a = str(predestine)
attempt()
def attempt():
attempt = input("Attempt:")
b = str(attempt)
correctrecord = []
sequencerecord = []
for i in b:
if i in a:
correctrecord.append(1)
for i in range(0,4):
if b[i] == a[i]:
s equencerecord.append(1)
correctlength = len(correctrecord)
sequencelength = len(sequencerecord)
print(f"You have made {correctlength} correct attempts, and of these {sequencelength} are of correct positions")
if sequencelength == 4:
print("You have won, the game is ended")
else:
return attempt()
The problem is with the last code: return attempt(). It seems it fails to repeat the function with 'str object not callable' error.
The problem in your code lies in variable shadowing.
Your repeated function is in a variable named attempt, a global variable. Then, inside the attempt function you define an attempt string variable, local to this function, and therefore temporarily shadowing the global attempt variable that held the function.
Therefore, the call attempt() fails, as you're essentially trying to call a string.
The solution would be to rename the local string variable attempt to not shadow the global one:
def attempt():
attempt_ = input("Attempt:")
b = str(attempt_)
correctrecord = []
sequencerecord = []
for i in b:
if i in a:
correctrecord.append(1)
for i in range(0,4):
if b[i] == a[i]:
sequencerecord.append(1)
correctlength = len(correctrecord)
sequencelength = len(sequencerecord)
print(f"You have made {correctlength} correct attempts, and of these {sequencelength} are of correct positions")
if sequencelength == 4:
print("You have won, the game is ended")
else:
return attempt()
Your use same variable-names multiple times. Python functions are first class citizens, which allows you to do:
# define a function by name r
def r():
return 1
print(type(r)) # <class 'function'> now r is a function
# reassign name r to be a string
r = "22"
print(type(r)) # <class 'str'> now r is a string
If you do r() now you get TypeError: 'str' object is not callable
Your code uses global variables and you call your own function again and avain - this can lead to recursion overflow - see What is the maximum recursion depth in Python, and how to increase it?
You will get wrong results when calculating the amount of correct "digits" when there are duplicates - try "1122" as correct value and "1234" as attempt.
Recursion is not needed to code your game. I restructured it a bit to showcase a different way:
def getnumber(text):
"""Loops until a number is inputted. Returns the number as string.
'text' is the prompt for the user when asking for a number."""
while True:
try:
predestine = int(input(text).strip())
return str(predestine)
except:
print("Only numbers allowed!")
def attempt(correct_number):
"""One game round, returns True if correct result was found."""
attempt = getnumber("Attempt: ")
# avoid double-counting for f.e. 1212 and 1111 inputs
correct_digits = len(set(attempt) & set(correct_number))
sequencelength = 0 # no need to collect into list and use len
for i,c in enumerate(attempt): # simply increment directly
if c == correct_number[i]:
sequencelength += 1
print(f"You have found {correct_digits} correct digits, and of these {sequencelength} are of correct positions.")
if len(attempt) < len(correct_number):
print("Your number has too few digits.")
elif len(attempt) > len(correct_number):
print("Your number has too many digits.")
return correct_number == attempt
# game - first get the correct number
number = getnumber("Please input your test number: ")
# loop until the attempt() returns True
ok = False
while not ok:
ok = attempt(number)
print("You have won, the game is ended")
Output:
Please input your test number: 1234
Attempt: 1111
You have found 1 correct digits, and of these 1 are of correct positions.
Attempt: 1212
You have found 2 correct digits, and of these 2 are of correct positions.
Attempt: 1321
You have found 3 correct digits, and of these 1 are of correct positions.
Attempt: 1234
You have found 4 correct digits, and of these 4 are of correct positions.
You have won, the game is ended

Python: Issue with Elif Break

I'm trying to make a simple program that will take all of your lottery numbers, and compare them (using set intersect) with the winning numbers that you input.
I've gotten the groundwork laid where you enter your numbers, it gets submitted to a sublist, which will then be converted into five separate sets, which will be used to compare. However, when you run the script, the while loop will not break when the length of the list is 5 (this is the goal).
Can someone explain what I'm doing wrong? Or maybe even a better way of working this whole program. I'm relatively new to the world of Python, I'm just diving in, and trying to make this program work.
# Start Program
def set_convert(list):
conversion = set(list)
return conversion
def comparison(winning_numbers, my_numbers):
pass
def main():
print('Welcome to the Lottery Checker v1.0!')
winning_numbers = [int(x) for x in input('Enter the winning numbers(Sep w/ Spaces): ').split()]
winning_set = set_convert(winning_numbers)
my_numbers = []
while True:
numbers = [int(x) for x in input('Enter your numbers(Sep w/ Spaces Max: 5): ').split()]
if len(numbers) == 6:
my_numbers.append(numbers)
print('Added! Want to add more?')
elif len(my_numbers) == 5:
break
else:
pass
else:
pass
print('Here are your numbers: {}. Good luck! :-)'.format(my_numbers))
main()
Replace
elif len(my_numbers) == 5:
with
elif len(numbers) == 5:
Also, it is advisable that you don't use the keyword list as an argument for the function set_convert. Rather, define it as:
def set_convert(mylist):
conversion = set(mylist)
return conversion
And finally, you don't need to pass in my_numbers and winning_numbers into the function comparison as arguments since they are available in the outer scope.

Produce a function that receives the die value and the total number of rolls and prints a single line of the histogram based on the values passed

"You will need to call the function once per possible die value."
I'm a programming noob and have spent about seven hours trying to figure this out.
My code is just a conglomeration of ideas and hopes that I'm headed in the right direction. I desperately need help and want to understand this stuff. I've scoured the message boards for my specific issue in vain. Please assist...
I realize my code is spitting out the result for every possible roll. When I need a program that I.E. when someone chooses to roll 50 times and designates 2 as the die value they desire to single out. The histogram would display how many times 2 was randomly rolled out of 50 rolls as asterisks on a single line of histogram.
My code thus far:
import random
def dice_sum(rolls):
results = 0
dice_sum = 0
for i in range(0, rolls):
results = random.randint(1, 6)
print("Die %d rolled %d." % (i+1, results))
dice_sum += results
print("Total of %d dice rolls is: %d" % (rolls, dice_sum))
return dice_sum
def hist_gram():
hist_gram='*'
dievalue= int(input('Which specific value between 1 and 6 are you requesting? [enter a #]'))
# get user input
rolls = int(input('How many times would you like to roll the 6 sided die? [enter a #]'))
dievalue= int(input('Which specific value between 1 and 6 are you requesting? [enter a #]'))
# pass input values to function and print result
result = dice_sum(rolls=rolls)
print(result)
You're making a mountain out of a molehill. Slow down and think about the problem. They want you to do an action a bunch of times. Then based on what each result is, do something with that information.
We can use a for loop to do the actions many times, as you've used. Then we can check the result using a simple if statement. You're trying to do the processing after the fact and it's making your life more difficult than it needs to be.
Our solution becomes very simple:
import random
def dice_count(rolls, reqValue):
count = 0
for i in range(0, rolls):
if roll_the_dice() == reqValue:
count = count + 1
#Every time we encounter the value, we count up by one
#That's it! return count.
#Apparently we want a 'single line of a histogram',
# which is kind of a pointless histogram, don't you think?
#Turns out you can multiply against strings.
return count*'*'
def roll_the_dice():
#Apparently we need to call the function more than once? Confusing instruction.
return random.randint(1,6)
And now for the input:
You can use a try..catch block to deal with bad input. If someone inputs something that's not a number, the int conversion will create a ValueError. Instead of crashing, we can decide what happens when a ValueError is raised. If an error occurs, just start over - and keep trying until the user gets it right.
def main():
doInput()
def doInput():
rolls = 0
side = 0
#set up the variables, so we can access them outside the try..catch block
try:
rolls = int(raw_input("How many times should the die be rolled? "))
except ValueError:
print "That's not a valid number. Try again!"
doInput()
try:
side = int(raw_input("Which side?"))
if side < 1 or side > 6:
print "That's not a valid side of a die! Try again!"
do_input()
except ValueError:
print "That's not a valid number. Try again!"
do_input()
dice_count(rolls, side)
You'll want to store the result of each die role somehow, rather than just adding up the sum of your roles. This will also extend your function to be able to look at the results of all 50 results if you want, or just one roll at a time.
There are a few data structures you could use, but I'd recommend a dictionary because it's the most intuitive when dealing with storing values associated with events. For example:
from collections import defaultdict
import random
def dice_sum(rolls):
results = defaultdict(int)
for i in xrange(rolls):
this_roll = random.randint(1,6)
results[this_roll] += 1
return results
Running dice_sum(50):
>>> results = dice_sum(5)
>>> results[1]
11
>>> results[2]
5
>>> results[3]
6
>>> results[4]
13
>>> results[5]
8
>>> results[6]
7
Getting a histogram for a single line has been explained, so if you want the whole thing:
def histogram(results):
hist = ""
for i in xrange(1,7):
bar = '#' * results[i]
hist += '{}: {}\n'.format(i,bar)
return hist
Running it:
>>> print histogram(results)
1: ###########
2: #####
3: ######
4: #############
5: ########
6: #######

Using random.randint help in python

The following code is my attempt at simulating a lottery.
import random
def lottery(numbers):
lottoNumbers = [randint('0,100') for count in range(3)]
if numbers == lottoNumbers:
print('YOU WIN $10,000')
else:
print('YOU LOSE,DUN DUN DUNNN!')
return numbers
def main():
numbers = int(input('Enter a number: '))
if numbers == lottoNumbers:
numbers = lottery(numbers)
else:
numbers = lottery(numbers)
main()
Hey guys I've gotten this far with the help you've given me. I'm trying to write the code so that 3 lotto numbers at random will be chosen. Then the user must enter 3 of his/her own lotto numbers. If they get all 3 correct then they win the whole prize, if they get the 3 numbers but not in the correct order they win some of the prize. Obviously if they guess all wrong then a print statement would state that. What I'm confused about is how can I write the code so that the user can enter 3 numbers to try matching the random lottery numbers. I also want to print the 3 lottery numbers after the user inputs his/her choices. Any ideas guys?
Thanks for your help everyone.
You seem a bit confused about what the role of the arguments in a function are. You've said that your randm function takes the argument "number", but then you haven't actually used it anywhere. The next time number appears, you've assigned it a completely new value, so any value passed to randm isn't actually being used.
Also, the function is trying to return x, when x hasn't been assigned within the function. Either you already have a global variable called x already defined, in which case the function will just return that variable, or the function will just fail because it can't find the variable x.
Here's a quick example I've done where you pass their three numbers as a list as an argument to the function.
import random
theirNumbers=[5,24,67]
def checkNumbers(theirNumbers):
lottoNumbers = []
for count in range(3)
lottoNumbers.append(random.randint(0,100))
winning = True
for number in theirNumbers:
if not each in lottoNumbers: winning=False
if winning == True: print("Winner!")
There are a few things wrong with your implementation, to name a few:
if you are trying to compare the output of the function randm to x, you will need to include a return value in the function, like so:
def randm():
return return_value
You appear to be printing all the values but not storing them, in the end you will only end up with the final one, you should attempt to store them in a list like so:
list_name = [randint(0,100) for x in range(x)]
This will generate randint(0,100) x times in a list, which will allow you to access all the values later.
To fix up your code as close to what you were attempting as possible I would do:
import random
def randm(user_numbers):
number = []
for count in range(3):
number.append(random.randint(0, 100))
print(number)
return user_numbers == number
if randm(x):
print('WINNER')
If you are looking for a very pythonic way of doing this task,
you might want to try something like this:
from random import randint
def doLotto(numbers):
# make the lotto number list
lottoNumbers = [randint(0,100) for x in range(len(numbers))]
# check to see if the numbers were equal to the lotto numbers
if numbers == lottoNumbers:
print("You are WinRar!")
else:
print("You Lose!")
I'm assuming from your code (the print() specifically) that you are using python 3.x+
Try to post your whole code. Also mind the indentation when posting, there it looks like the definition of your function would be empty.
I'd do it like this:
import random
def lottery():
win = True
for i in range(3):
guess = random.randint(1,100)
if int(raw_input("Please enter a number...")) != guess:
win = False
break
return win
Let so do this in few steps.
First thing you should learn in writing code is to let separate pieces of code( functions or objects) do different jobs.
First lets create function to make lottery:
def makeLottery(slotCount, maxNumber):
return tuple(random.randint(1,maxNumber) for slot in range(slotCount))
Next lets create function to ask user's guess:
def askGuess(slotCount, maxNumber):
print("take a guess, write {count} numbers separated by space from 1 to {max}".format(count = self.slotCount, max = self.maxNumber))
while True: #we will ask user until he enter sumething suitable
userInput = raw_input()
try:
numbers = parseGuess(userInput,slotCount,maxNumber)
except ValueError as err:
print("please ensure your are entering integer decimal numbers separated by space")
except GuessError as err:
if err.wrongCount: print("please enter exactly {count} numbers".format(count = slotCount))
if err.notInRange: print("all number must be in range from 1 to {max}".format(max = maxNumber))
return numbers
here we are using another function and custom exception class, lets create them:
def parseGuess(userInput, slotCount,maxNumber):
numbers = tuple(map(int,userInput.split()))
if len(numbers) != slotCount : raise GuessError(wrongCount = True)
for number in numbers:
if not 1 <= number <= maxNumber : raise GuessError(notInRange = True)
return numbers
class GuessError(Exception):
def __init__(self,wrongCount = False, notInRange = False):
super(GuessError,self).__init__()
self.wrongCount = wrongCount
self.notInRange = notInRange
and finally function to check solution and conratulate user if he will win:
def checkGuess(lottery,userGuess):
if lottery == userGuess : print "BINGO!!!!"
else : print "Sorry, you lost"
As you can see many functions here uses common data to work. So it should suggest you to collect whole code in single class, let's do it:
class Lottery(object):
def __init__(self, slotCount, maxNumber):
self.slotCount = slotCount
self.maxNumber = maxNumber
self.lottery = tuple(random.randint(1,maxNumber) for slot in range(slotCount))
def askGuess(self):
print("take a guess, write {count} numbers separated by space from 1 to {max}".format(count = self.slotCount, max = self.maxNumber))
while True: #we will ask user until he enter sumething suitable
userInput = raw_input()
try:
numbers = self.parseGuess(userInput)
except ValueError as err:
print("please ensure your are entering integer decimal numbers separated by space")
continue
except GuessError as err:
if err.wrongCount: print("please enter exactly {count} numbers".format(count = self.slotCount))
if err.notInRange: print("all number must be in range from 1 to {max}".format(max = self.maxNumber))
continue
return numbers
def parseGuess(self,userInput):
numbers = tuple(map(int,userInput.split()))
if len(numbers) != self.slotCount : raise GuessError(wrongCount = True)
for number in numbers:
if not 1 <= number <= self.maxNumber : raise GuessError(notInRange = True)
return numbers
def askAndCheck(self):
userGuess = self.askGuess()
if self.lottery == userGuess : print "BINGO!!!!"
else : print "Sorry, you lost"
finally lets check how it works:
>>> lottery = Lottery(3,100)
>>> lottery.askAndCheck()
take a guess, write 3 numbers separated by space from 1 to 100
3
please enter exactly 3 numbers
1 10 1000
all number must be in range from 1 to 100
1 .123 asd
please ensure your are entering integer decimal numbers separated by space
1 2 3
Sorry, you lost
>>> lottery = Lottery(5,1)
>>> lottery.askAndCheck()
take a guess, write 5 numbers separated by space from 1 to 1
1 1 1 1 1
BINGO!!!!

Categories

Resources