words = []
words_needed = 0
def input_words():
inputWords = input('Please input more words that you want to play with.').lower()
words.append(inputWords)
words_needed += 1
while words_needed < 5:
input_words()
else:
words_needed >= 5
input_SS = input('Do you want to continue adding words?')
if input_SS == 'yes':
input_words()
elif input_SS == 'no':
end
def Start_up():
start_question = input('Do you want to add your own words to the list?')
if start_question == 'yes':
input_words()
elif start_question == 'no':
pre_words = (*words in a list*)
words.extend(pre_words)
Start_up()
When I run this segment of code it either runs off forever of brings me back an error of;
Traceback (most recent call last):
File "F:\A453\Code\Python Hangman\Hangman.py", line X, in <module>
Start_up()
File "F:\A453\Code\Python Hangman\Hangman.py", line Y, in Start_up
input_words()
File "F:\A453\Code\Python Hangman\Hangman.py", line Z, in input_words
words_needed += 1
UnboundLocalError: local variable 'words_needed' referenced before assignment
Im fairly new to coding so any help would be appreciated