Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
def not_alone(nums, val):
for e in nums:
if e == val:
s = nums.index(e)
if s != 0 and s != (len(nums) - 1):
nums[s] = max(nums[s-1], nums[s+1])
return nums
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment