

It looks like we could eliminate all that by just considering uppercase versions of lst when testing. I don't really follow the logic in the if element.isupper() test. Since its scope is small, I'd go for a very short name, such as c. There's no point assigning to new_list, since we immediately replace that with a copy of lst.Įlement is a long name for iterating over characters. We could use element.isalpha() for that: if element.isalpha(): I think it would be better to check whether a character is alphabetic, and hide those, revealing only the ones that don't match any alphabetic letter. missing ', which is present in many words, including the first one of this sentence). That's also a good place for the unit tests, if we use the doctest module.Īlphanumerical_characters is a misleading name for that variable - it seems to be intended as a list of non-alphabetic characters. Result += element #in second for loop we check if there's space between characters, element not in new_list, element in listĪny non-trivial function ought to have a docstring describing its purpose and any constraints on its arguments. New_list.append(element) #this for loop requires if element is uppercase, make lowercase and then check if its in lst New_list = lst.copy() #we create copy of that to get the lowercase elements New_list = #creating new_list because i want to take the uppercase letters and lowercase letters #if requires from A-Z and numbers 1-9 and other symbols Does the built in functions used as a cheating? def hangman(phrase, lst):Īlphanumerical_characters = #characters which are alphanumerical
#Create hangman game how to
I saw people solved this in a one line but is it my solution good? I want to take everything and solving into smaller pieces and how to improve the solution any please explain why is it better to use that solution.

