d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Need Help In Python > For A Mastermind
Prev123Next
Add Reply New Topic New Poll
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
May 24 2014 07:42pm
put a log statement before/after every single time you use it. you'll find a spot where it's doing something you're not expecting.
Member
Posts: 27,086
Joined: Mar 7 2008
Gold: 685.00
May 24 2014 09:08pm
Quote (carteblanche @ 24 May 2014 20:42)
put a log statement before/after every single time you use it. you'll find a spot where it's doing something you're not expecting.


ok fixed but got another problem


i got a list like that [[0,0,0,0,0], [0,0,0,0,1], [0,0,0,0,2], [0,0,0,0,3],[0,0,0,0,5],...[7,7,7,7,7]]
if i remove at range 1,2,3 on the list i got [[0,0,0,0,0], [], [], [],[0,0,0,0,5],...[7,7,7,7,7]] but I would like to be removed like this [[0,0,0,0,0],[0,0,0,0,5],...[7,7,7,7,7]]
is it possible without if len(totall[z])>0:
because it may rand an empty list

This post was edited by eric838 on May 24 2014 09:10pm
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
May 24 2014 09:21pm
Quote (eric838 @ May 24 2014 11:08pm)
ok fixed but got another problem


i got a list like that [[0,0,0,0,0],  [0,0,0,0,1], [0,0,0,0,2], [0,0,0,0,3],[0,0,0,0,5],...[7,7,7,7,7]]
if i remove at range 1,2,3  on the list i got  [[0,0,0,0,0],  [], [], [],[0,0,0,0,5],...[7,7,7,7,7]]  but I would like to be removed like this  [[0,0,0,0,0],[0,0,0,0,5],...[7,7,7,7,7]]
is it possible  without      if  len(totall[z])>0:
because it may rand an empty list


remove should do it.

Quote
Python 2.7.5+ (default, Sep 19 2013, 13:48:49)
[GCC 4.8.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> mylist = ['first', 'second']
>>> mylist
['first', 'second']
>>> mylist.remove('first')
>>> mylist
['second']


/edit: or by index use del

Quote
>>> mylist = ['first', 'second']
>>> mylist
['first', 'second']
>>> del mylist[0]
>>> mylist
['second']
>>>


This post was edited by carteblanche on May 24 2014 09:24pm
Member
Posts: 27,086
Joined: Mar 7 2008
Gold: 685.00
May 24 2014 09:30pm
Quote (carteblanche @ 24 May 2014 22:21)
remove should do it.



/edit: or by index use del


yep but if i remove range 1-2-3

[[0,0,0,0,0], [0,0,0,0,1], [0,0,0,0,2], [0,0,0,0,3],[0,0,0,0,5],...[7,7,7,7,7]] I will get this [[], [], [7,7,7,7,7]] range 1-2-3 removed from list but all the others lists in the big list get empty [] except for the last range
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
May 24 2014 09:37pm
Quote (eric838 @ May 24 2014 11:30pm)
yep but if i remove range 1-2-3 

[[0,0,0,0,0],  [0,0,0,0,1], [0,0,0,0,2], [0,0,0,0,3],[0,0,0,0,5],...[7,7,7,7,7]] I will get this  [[], [], [7,7,7,7,7]] range 1-2-3 removed from list but all the others lists in the big list get empty [] except for the last range


what is your code? it's working fine for me using del
Member
Posts: 27,086
Joined: Mar 7 2008
Gold: 685.00
May 24 2014 10:08pm
Quote (carteblanche @ 24 May 2014 22:37)
what is your code? it's working fine for me using del


[[0, 0, 0, 0, 0]
[]
[0, 0, 0, 0, 2]
[]
[]
[0, 0, 0, 0, 5]
[0, 0, 0, 0, 6]]

if i got a list like this, len is 7 right?

btw code is the same just added a line after rand a combination if not exactly the same to delete it in the list
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
May 24 2014 10:33pm
how about you post the single line of code where you're deleting the entries? as i said, del works fine for me. i'm not digging through your code.
Member
Posts: 27,086
Joined: Mar 7 2008
Gold: 685.00
May 25 2014 07:54pm
Quote (carteblanche @ 24 May 2014 23:33)
how about you post the single line of code where you're deleting the entries? as i said, del works fine for me. i'm not digging through your code.


Code
if rcolrplace != rcolrplace2 or rcolorwplace != rcolorwplace2:
del totall[z]
z = z - 1
lLength = lLength - 1
z = z + 1
Member
Posts: 27,086
Joined: Mar 7 2008
Gold: 685.00
May 26 2014 10:37pm
Quote (carteblanche @ 24 May 2014 23:33)
how about you post the single line of code where you're deleting the entries? as i said, del works fine for me. i'm not digging through your code.


ok entries got deleted but not deleted entries get empty
Member
Posts: 11,610
Joined: Oct 28 2008
Gold: 1,795.00
May 27 2014 04:19am
Might consider dropping the class.
Go Back To Programming & Development Topic List
Prev123Next
Add Reply New Topic New Poll