0
nums = [1, 2, 3,5] nums(1)=nums(2)-0 if 2 in nums: nums.append 8 print(nums) else: nums.append(5) print(nums) print(nums)
Can anybody fix the error and write the correct code?
4 Answers
+ 2
Python requires indentation to indicate the end of blocks of code, such as what is in your else clause and what is after. So what you need are tabs on the lines within the if and else sections. That should get you on the move!
+ 2
Still an indentation error? That formatting looks about right... If so, try spaces instead of the tabs, perhaps.
+ 1
nums = [1, 2, 3,5]
nums(1)=nums(2)-0
if 2 in nums:
nums.append 8
print(nums)
else:
nums.append(5)
print(nums)
0
This shows error