How to create a loop to return to the start of a function python
<p>I am unable to get my <code>while</code> loop to start back at the beginning not to sure what is wrong.</p>

<p>First attempt</p>

<pre><code>def start() :

if choice in weapon:
    print('You have taken the ') + choice + (',this is now in your backpack.\n')  
    inventory.append(choice)

else:
    print("Uh oh, I don't know about that item")

start()  
</code></pre>

<p>second attempt</p>

<pre><code>the_choice = False
while not the_choice:
if choice in weapon:
    print('You have taken the ') + choice + (',this is now in your backpack.\n')  
    inventory.append(choice)
    the_choice = True
     # boom no loop needed 
else:
    print("Uh oh, I don't know about that item")
    the_choice = False  
</code></pre>

<p>I just can't seem to figure it out. </p>

<p>There are only indentation faults in the second attempt.
Try below code.</p>

<pre><code>the_choice = False
while not the_choice:
    if choice in weapon:
        print('You have taken the ') + choice + (',this is now in your backpack.\n')  
        inventory.append(choice)
        the_choice = True
        # boom no loop needed 
    else:
        print("Uh oh, I don't know about that item")
        the_choice = False
</code></pre>

<p>This will stuck in a constant loop if the user keeps entering a value not in the list (weapon), so you can put a counter for every <code>False</code> and update like below.</p>

<pre><code>counter=0
the_choice = False
while not the_choice:
    if choice in weapon:
        print('You have taken the ') + choice + (',this is now in your backpack.\n')  
        inventory.append(choice)
        the_choice = True
        # boom no loop needed 
    else:
        print("Uh oh, I don't know about that item")
        the_choice = False
        counter=counter+1

    if counter &gt;= 3:
        print('You have made 3 wrong attempts ')
        break
</code></pre>

python python-2.7