Lol, now I’m the one needing to be helped
So I challenged myself to make a game without any indentation/tabs and started making hangman. The project was doing well so far until…
Traceback (most recent call last):
File "main.py", line 5, in <module>
while wordArr != list(word): os.system('clear'); print(stickString if wrongCount < len(stickString) else stickString[-1]); print(f"Count: {count}"); print(wordArr); x = input(""); wrongCount = compare(word, x, wrongCount); count += 1
TypeError: '<' not supported between instances of 'list' and 'int'
And what’s odd about this is because I checked the variable types before the while loop started, and both are showing up as integers. Both len(stickString) and wrongCount are integers.
Since it was only checking their types before the while loop starts, my line of thinking is that something is happening that is inadvertently turning something into a list. But I can’t see in the code where that could possibly happen! I hope any of you can help me in this predicament.
Here’s the code:
import random, os;
word, stickString, wordArr, count, wrongCount = random.choice(["apple", "dogs", "something"]), " ____\n | |\n |\n |\n |\n _|_", [], 0, 0
for i in range(len(word)): wordArr.append("_")
compare = lambda word, x, wrongCount: [(z := i, wordArr.__setitem__(z, x)) for i, letter in enumerate(word) if letter == x] or wrongCount + 1
while wordArr != list(word): os.system('clear'); print(stickString if wrongCount < len(stickString) else stickString[-1]); print(f"Count: {count}"); print(wordArr); x = input(""); wrongCount = compare(word, x, wrongCount); count += 1
os.system('clear')
print(wordArr)
I created spaces between some of the lines for readability for you all.
note: (any fixes for this has to not need indentation for new lines, because that’s the point of the challenge)