Steps of interpreting how this operation runs
Question: I was wondering if anyone could tell me step by step how these operations run.
I'm not sure how they are being executed the way they are and I would like to
understand. Thank you

    
    
     >>>s = 'Fuzzy wuzzy was a bear'
     >>>t=''
     >>>j=4
     >>>for w in s.split():
           if j%2 == 0:
              t = w[0] + t
           j-=1
     >>>print(t)
     bwF
    

As well as this one:

    
    
     >>>s = 'Fuzzy wuzzy was a bear'
     >>>p = ''
     >>>q = False
     >>>for ch in s[:5]:
            if q:
                p+=ch
            if ch == 'u':
                q = not q
    
     >>>print(p)
     zzy
    

If anyone could explain the steps python takes to interpreting this and
executing it to get the results that it does, I would really appreciate it.


Answer: What you could do is use python debugger pdb like so :

    
    
    import pdb
    pdb.set_trace()
    s = 'Fuzzy wuzzy was a bear'
    t=''
    j=4
    for w in s.split():
        if j%2 == 0:
            t = w[0] + t
        j-=1
    print(t)
    

With this, you will be able to execute your code step by step and print the
values after any instruction. You can read more about it
[here](http://docs.python.org/2/library/pdb.html)

