[Tutor] Function not using updated variable?

Steven D'Aprano steve at pearwood.info
Sun Jan 20 20:17:33 EST 2019


Hi Ello, and welcome!

On Mon, Jan 21, 2019 at 01:14:55AM +0100, Ello Solcraft wrote:

> # currLocation doesn't use the updated variable.

How do you know?

I'm sorry, but it is impossible for me to tell what is going on here. 
There simply isn't enough information to understand your code.

We don't know what inputList, currCalc, mapLocation or mapInput do. We 
don't know how you know that currLocation doesn't "use the updated 
variable" (currCalc2), or what you mean by "use".

When asking for help to solve a problem like this, it is very helpful if 
you can provide SIMPLE code we can run ourselves, as well as the results 
you expect and the results you actually get.

(We're volunteers, and you are not paying us to troll through 200 or 300 
lines of code looking for a bug. Keep it short and simple.) 

More comments below.

> for x in inputList:
>         currCalc.append(x)
>         currCalc2 = ''.join(currCalc)
>         currLocation = mapLocation(mapInput(currCalc2))#mapInput(currCalc2))
> 
> # I tried printing currCalc2, it updates like it should. But currLocation
> doesn't use the updated currCalc2. 

How do you know? What happens if you print(currLocation) each time 
through the loop?

What do mapInput and mapLocation do? If currLocation never changes its 
value, perhaps one of mapInput or mapLocation always returns the same 
thing?



-- 
Steve


More information about the Tutor mailing list