Oct-10-2018, 04:32 PM
(This post was last modified: Oct-10-2018, 04:32 PM by ichabod801.)
You shouldn't have 24 variables named number1-number24, you should have a list of 24 values. Same with char_list. You assign char_list like so:
You are not assigning to a set anywhere. There is no set anywhere in your code. A set is a container that has one and only one of each value in it, and provides fast access to the 'in' operator. You just have a bunch of integers and strings.
The reason it prints 0000000 forever is that you are printing attempts. That variable is the sum of the char_list variables. You never change the char_list variables, so attempts never changes, so you always print the same thing. Changing number1 does not retroactively change the assignment of char_list1 to chars[number1]. You have to reassign that if you want attempts to change.
Edit: It looks like a lot of others pointed all of this out while I was typing it up. Listen to everything they said.
chars[number2][0]
. But since chars is a string, chars[number2] returns a string of length 1. All the [0] is return the first character of a string of length one, which is the string.You are not assigning to a set anywhere. There is no set anywhere in your code. A set is a container that has one and only one of each value in it, and provides fast access to the 'in' operator. You just have a bunch of integers and strings.
The reason it prints 0000000 forever is that you are printing attempts. That variable is the sum of the char_list variables. You never change the char_list variables, so attempts never changes, so you always print the same thing. Changing number1 does not retroactively change the assignment of char_list1 to chars[number1]. You have to reassign that if you want attempts to change.
Edit: It looks like a lot of others pointed all of this out while I was typing it up. Listen to everything they said.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures