15,662,426 members
1.00/5 (1 vote)
See more:
Now out of this list of lis how can I find a maximum number???
NOTE: max() is showing a NoneType Error

What I have tried:

Python
```def adjacentElementsProduct(inputArray):
for i in range(0, len(inputArray)-1):
lis=(inputArray[i]*inputArray[i+1])
print(lis)```
Posted
Updated 14-Apr-23 7:09am
v2
Patrice T 14-Oct-17 14:39pm
Where is the max function in your code ?

## Solution 1

What you are looking for is the largest product of two numbers in a list: which means multiplying each pair and comparing each against the previous maximum, not just printing each product.
So try this:
1) Create a variable outside the loop, call it `maxSoFar` and set it to the product of the first pair.
2) Loop through each element (except the final one)
2.1) Multiply each element by the one after it.
2.2) Compare that value with `maxSoFar`
2.2.1) If it's larger, set `maxSoFar` to the new product.
3) Continue with the loop
4) After the loop, print `maxSoFar`

Simple! But ... this is your homework, so I'll give you no code! Give it a try - this really isn't a difficult task.

## Solution 3

Python
```def adjacentElementsProduct(inputArray):
lst1 = 0
for i in range(0, len(inputArray)-1):
lst2 = inputArray[i] * inputArray[i+1]
if lst2 > lst1:
lst1 = lst2<
return lst1```

v3
Richard MacCutchan 23-Jun-20 5:04am
"try to provide proper indentation"
Which you forgot to do. Also, this question is nearly three years old, so it is unlikely that the OP is still waiting for an answer.

## Solution 10

```def adjacent_element_product(inputArray):
multi=[inputArray[i]*inputArray[i+1]
for i in range(0, len(inputArray)-1)]
print(multi)```

v3