I want to write a code that replaces a certain string '-1' with '0' on the list. But I'm having a hard time writing if statements.
list = [-1, 1, -1]
if '-1' in list:
code that replace -1 to 0 <--- What I want to add
else:
pass
What I tried to do was the code below.
if i in list:
temp = i.replace("-1","0")
list.append(temp)
print(list)
else:
pass
But this code shows "NameError: name 'i' is not defined".