I have a fairly basic python issue, here's the code:
def LCM(nums):
i = max(nums)
var = 0
x = 0
while i>0:
for x in nums:
var = var+int(nums[x])%i
if (var == 0):
return i
i=i-1
nums is a list, I think x is the index for that list, and the for statement should iterate through each value in the list as nums[x]. It seems like x should start at the first element of nums, and iterate through each value till nums runs out of values.
Instead, I get list index out of range, I don't understand how this is possible.
Is my for syntax screwed up? I can't make this make sense.