I have very little experience in coding and I'm learning Python in a class. I'm learning about conditionals and loops and have been asked to create a function that'll take an arbitrary amount of arguments and give me the maximum. Obviously I'm not allowed to use the built-in max function.
So far, I have:
def max(x):
current_max = x[1]
for i in x[i]:
if x[i] > current_max:
current_max = x[i]
When I run the code, it gives me no errors, but when I try to run max() it'll only accept one argument. The only idea that came to mind was adding in:
x = input('Enter numbers to compare:')
When I ran this, I got:
UnboundLocalError: local variable 'i' referenced before assignment
And I'm unsure of what I can do at this point as I'm unsure of whether or not I'm not defining the argument correctly or there's just an error in the code defining max(x) that didn't show up in the first time for some reason.