I am trying a short code that uses an array, I basically want to replace the word hate for love when I call my function WordReplace but I keep printing the same thing:
I
If you want to assign a new value to a variable you need the following syntax:
myVar = myValue;
This will change the value of myVar to myValue.
This construction:
myVar == myValue
is a comparison and is treated as a bool, since it returned true(if myVar equals myValue) and False (if they are not equal). The construction doesn't change the value of myVar or myValue.
In your case you need to replace x[z] == w
by x[z] = w
, as suggested by Igor