Below I have a script that I have done while trying to complete for a assignment I have.
What the script is suppose to do is ask the user for 2 inputs and then return the greater of the inputs. (This I havent figured out completely yet)
The point of this assignment is too see what happens if I instead of entering 2 numbers, enter two words "Hej" and "Hå".
What I need some advice on is how to enable this script to accept 2 user inputs and return the greater of them two.
def maximum(x, y):
i = 0
maxnra = 0
maxnrb = 0
while i < len(x) :
if x[i] > maxnra:
maxnra = x[i]
i = i + 1
else:
i = i + 1
print "I första ordet är maximum: ", maxnra
i = 0
while i < len(y) :
if y[i] > maxnrb:
maxnrb = y[i]
i = i + 1
else:
i = i + 1
print "I andra ordet är maximum: ", maxnrb
maximum("hej", "hå")
EDIT:
I tried working this out another way, is this a way to solving this?
print "First"
x = input()
print "Second"
y = input()
def printMax(x, y):
if x > y:
print(x, 'is maximum')
elif a == b:
print(x, 'is equal to', y)
else:
print(y, 'is maximum')
right now im missing something cause it's not returning anything when I enter the 2 values.