Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- import math
- import re
- def getRandomNumber():
- random_list = []
- NUM_NUMBERS = 4
- for i in range(0,NUM_NUMBERS):
- random_list.append(random.randrange(1,10))
- print('Four given numbers:', ','.join([str(x) for x in random_list]))
- return random_list
- def checkUserInput(numberList,userInput):
- numbers_in_user_input = re.findall('\d+',userInput)
- if list.sort(numbers_in_user_input) == list.sort(numberList):
- print('right')
- else:
- print('wrong')
- print(numbers_in_user_input)
- print(numberList)
- def main():
- number_list = getRandomNumber()
- user_input = input("Please enter an equation that equals 24 based on the given numbers using 'x' for multiplcation, '/' for division, '+' for addition and '-' for subtraction: ")
- checkUserInput(number_list,user_input)
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement