Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Not adding and assigning?
#5
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: 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
Reply


Messages In This Thread
Not adding and assigning? - by 00712411 - Oct-10-2018, 03:47 PM
RE: Not adding and assigning? - by nilamo - Oct-10-2018, 04:15 PM
RE: Not adding and assigning? - by volcano63 - Oct-10-2018, 04:23 PM
RE: Not adding and assigning? - by 00712411 - Oct-10-2018, 04:27 PM
RE: Not adding and assigning? - by volcano63 - Oct-10-2018, 04:33 PM
RE: Not adding and assigning? - by nilamo - Oct-10-2018, 04:35 PM
RE: Not adding and assigning? - by volcano63 - Oct-10-2018, 07:11 PM
RE: Not adding and assigning? - by ichabod801 - Oct-10-2018, 04:32 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Assigning a new value to variable uriel 1 1,615 Dec-04-2021, 02:59 PM
Last Post: Underscore
  assigning a variable :( gr3yali3n 0 1,335 Sep-22-2020, 09:02 PM
Last Post: gr3yali3n
  Assigning variables Godserena 4 2,212 Apr-26-2020, 06:59 AM
Last Post: buran
  Assigning a Variable Help MC2020 5 2,963 Jan-06-2020, 10:54 PM
Last Post: MC2020
  Adding markers to Folium map only adding last element. tantony 0 2,136 Oct-16-2019, 03:28 PM
Last Post: tantony
  Assigning an item from a list xlev 1 1,469 Sep-27-2019, 04:42 PM
Last Post: Larz60+
  assigning index 3Pinter 6 3,040 Jan-18-2019, 10:07 PM
Last Post: nilamo
  Assigning iter_row value to variable ankey 8 9,098 Sep-24-2018, 03:51 PM
Last Post: ankey
  Assigning a new variable in a IF loop pythoneer 5 3,818 Mar-02-2018, 05:21 AM
Last Post: pythoneer
  Assigning to string slice michaeljhuman 1 2,778 Feb-08-2018, 12:57 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020