Guys need help! (Programming!)

Kinja'd!!! "Cherry_man1" (Cherry_man1)
10/02/2014 at 19:13 • Filed to: Programming help

Kinja'd!!!0 Kinja'd!!! 15

ok keep getting some wonky errors and I don;t understand them.

Programmers of oppo help!

Kinja'd!!! Kinja'd!!! Kinja'd!!!

Have a lambo for your time.


DISCUSSION (15)


Kinja'd!!!  > Cherry_man1
10/02/2014 at 19:16

Kinja'd!!!3

Kinja'd!!!


Kinja'd!!! bob and john > Cherry_man1
10/02/2014 at 19:19

Kinja'd!!!0

what BnS said. I'm not looking forward to programming next sem


Kinja'd!!! Matsch > Cherry_man1
10/02/2014 at 19:25

Kinja'd!!!2

Try using pastebin.com or codeshare.io instead of posting a screenshot.


Kinja'd!!! Sportwägen, Driver Of The Red Sportwagen > Cherry_man1
10/02/2014 at 19:44

Kinja'd!!!1

Someone else who is experiencing the hell that is Python! *high five*


Kinja'd!!! Sportwägen, Driver Of The Red Sportwagen > Cherry_man1
10/02/2014 at 19:46

Kinja'd!!!0

Your issue is the _int affix. You need to change them to _str... Try it


Kinja'd!!! Tekamul > Cherry_man1
10/02/2014 at 19:48

Kinja'd!!!0

Not really my language (is it Python?), but it looks like you are trying to do boolean comparisons (T/F) with variables declared as integers (can only see last example, line 86, assuming others are similar).


Kinja'd!!! 48 Spoons > Cherry_man1
10/02/2014 at 19:49

Kinja'd!!!0

Not super experienced in python, but from what i can gather from the error message is that self._rows is and int and not some sort of collection that you can iterate over. I would check what self._rows is set to in the isGameOver function


Kinja'd!!! Matsch > Cherry_man1
10/02/2014 at 20:21

Kinja'd!!!1

You can't iterate over an integer. Try changing all of you "for row in self_rows" loops to "for row in range(self._rows)" and your column loops to use the range function as well.

As a side note, your code could use some refactoring. If you put the whole thing somewhere online that _isn't_ a screenshot I could help you refactor it.


Kinja'd!!! Matsch > Matsch
10/02/2014 at 20:37

Kinja'd!!!0

Also consider using list comprehension for the first for loop with board.append. And instead of doing board.append you could do board[row] = [0]*columns. Also you dont need to use the rows and columns variables so you dont really need _rows and _columns variables. Try using len(board) to get the rows. and len(board[row]) where row is is the row number where you want to get the number of columns.


Kinja'd!!! Snooder87 > Matsch
10/02/2014 at 20:55

Kinja'd!!!0

Lol I was trying to figure out how he got it to initialize at all. Looks like he got the "range" right in the initial function but not in the others.


Kinja'd!!! Matsch > Matsch
10/02/2014 at 20:57

Kinja'd!!!0

I meant to say you dont need the _rows and _columns inner variables because you are instantiating up front from the parameters you pass in to the object, and the rows and columns can be calculated from the board. Which is actually cleaner and more flexible code.


Kinja'd!!! Cherry_man1 > Matsch
10/02/2014 at 21:23

Kinja'd!!!0

Code

!!! UNKNOWN CONTENT TYPE !!!

Here is the code


Kinja'd!!! Axial > 
10/02/2014 at 22:32

Kinja'd!!!0

I took Python Summer 2013.

Thanks for reminding me how much I hate languages that don't use curly braces.

I would help you, but my brain is in full-on Java mode right now and I can't even make sense of that code.


Kinja'd!!! Matsch > Cherry_man1
10/03/2014 at 15:11

Kinja'd!!!0

Here http://pastebin.com/ZZ0taMAV

There are a ton more things you could do here so I didn't go overboard. display_board needs fixing since it doesn't display in any reasonably readable fashion, but there are lots of options available for you there. Also, I forgot to add the value of the card you selected back in to the print statement, I deleted it by mistake.


Kinja'd!!! Cherry_man1 > Matsch
10/03/2014 at 15:38

Kinja'd!!!0

Ah gotcha, thanks for the help btw.