why argument of type 'NoneType' is not iterable is shown in my program
Question: i made this hangman program but it is giving 'nonetype' error whenever i run
it program running- Whenever I enter a word the output is like this Hang Man
Game Guess a word a \----- You gussed one word correctly

    
    
     -----a---------------
    
    Traceback (most recent call last):
      File "F:/coding/python/python programming for absolute beginners/chapter 5/Hang Man Game.py", line 129, in <module>
        if guess  in used:
    TypeError: argument of type 'NoneType' is not iterable
    

The code:

    
    
    print("\t\t\tHang Man Game")
    import random
    set=("happy","australia","punjab","criclet","tennis")
    choose=random.choice(set)
    correct=choose
    HANGMAN=('''
    _______
     |
     |
     |
     |
     |
     |
     |
     |
     |
     |
     |
    ___
    ''',
             '''
    ______________
     |     |
     |
     |
     |
     |
     |
     |
     |
     |
     |
    ___
    ''',
             '''
    ______________
     |     |
     |     O
     |
     |
     |
     |
     |
     |
     |
     |
    ___
    ''',
             '''
    ______________
     |     |
     |     O
     |     |
     |     |
     |     |
     |     |
     |     
     |     
     |     
     |     
    ___
    ''',
             '''
    ______________
     |     |
     |     O
     |     |
     |  ---|
     |     |  
     |     |
     |    
     |   
     |  
     |     
    ___
    ''',
             '''
    ______________
     |     |
     |     O
     |     |
     |  ---|---
     |     |  
     |     |
     |  
     |   
     |  
     |     
    ___
    ''',
             '''
    
    ______________
     |     |
     |     O
     |     |
     |  ---|---
     |     |  
     |     |
     |    / 
     |   /   
     |  /     
     |     
    ___
    ''',
             '''
    ______________
     |     |
     |     O
     |     |
     |  ---|---
     |     |  
     |     |
     |    / \
     |   /   \
     |  /     \
     |     
    ___
    '''
             )
    MAX_WRONG=(len(HANGMAN)-1)
    wrong=0
    new=""
    used=[]
    so_far="-"*len(correct)
    guess=raw_input("Guess a word\n")
    while(so_far!=correct and wrong<MAX_WRONG):
        print(so_far)
        if guess  in used:
            print("you have already used it")     
        else:
            if guess in correct:
                print("You gussed one word correctly\n")
                used.append(guess)
                for i in range(len(correct)):
                    if  guess==correct[i]:
                        new=new+guess
                    else:
                        new=new+so_far
                so_far=new
            else:
                used=used.append(guess)
                wrong=wrong+1
    


Answer: You cannot do this

    
    
    used = used.append(guess)
    

The `append` function returns `None`, it modifies `used` in place. So you are
basically appending `guess` on the right hand side, but then assigning `None`
to `used`. So the next iteration of the `while` loop you are trying to iterate
over `None`, which is what the error is telling you.

You simply need to say

    
    
    used.append(guess)
    

Or

    
    
    used += [guess]
    

