If I put in “Ab3” as a parameter, how would I go about to having the value “Ab4” returned to me?
The goal of this function is to take the 3rd character of a string and add one to it, unless it is four, in which case it would not add one and just exit. I don’t know how to obtain the “Ab4” that the function creates from “Ab3” and assign it back to the “area” variable.
def east(area):
area_list = list(area)
if "1" == area_list[2]:
area_list[2] = "2"
elif "2" == area_list[2]:
area_list[2] = "3"
elif "3" == area_list[2]:
area_list[2] = "4"
elif "4" == area_list[2]:
cannot_go(why)
else:
exit(0)
area = "".join(area_list)
You simply missed return statement in your function, you need it since you are using string input which is immutable. You can use the following code:
EDITED as per Chris comment