I'm a beginer in Python and I do not succeed to figure out how to solde the issues in my code. As my lecture do not provide any assistance, according to the online module that became mandatory because of the corona, I really need your help ! Before to go on the issues, there is the goals of my code :
The first function take as arguments 2 integers, and returns a random number between those integers. We will call this function get_rand_int. If the two integers are equals, this is an error and we will return None. (Hint: just put return None as your line for these cases.) We can test for the result of None in the second function and report that it was an error there. The second function, called print_random, asks for user input for one integer greater than 0, and if it receives good input, calls the first function. It converts the user input to an integer and calls the first function with 0 as the first argument and the user input as the second argument. We capture the output from the first function in a variable (e.g., rand = get_rand_int(0, input)). Our second function then prints out the number returned by the first function in a sentence: "Your random number is " and then the number.
For now, I think my code is in line with the goal ( just need to add something in the case of the first functiun would return "none") but I'm stuck with a small error which is making me stuck ! This error occurs when I'm trying to run the second function !
File "<ipython-input-83-f6b07c49d323>", line 2
def print_random():
^
SyntaxError: unexpected EOF while parsing
My code
import random
def get_rand_int(arg1, arg2):
rand = random.randint(arg1, arg2)
if float(rand) == float(arg1):
return None
elif float(rand) == float(arg1):
return None
else:
print(rand)
def print_random():
try :
prompt = int(input("Please enter an integer greater than 0:"))
assert(prompt > 0)
except:
print("Invalid input: You must input an integer greater than 0 for your input.")
rand = get_rand_int(0, input)
print( "Your random number is ",rand)
Thanks for your help !