*Failure Party*

We want to see you fail! Please share something that stumped you this week. Any error messages you couldn’t work around? Celebrating failure is a sure way to generate future success :smile:

The most frustrating failure I’ve had with Python was mixing spaces and tabs in the same file. In my text editor they looked the same, but machine was not happy about it!! Took me lots of very hard head scratching to figure out what the problem was.

1 Like

I don’t think there is enough space on the interweb for all my frustrating code :smile:

1 Like

My failure this week was, due to an onset of laziness, to write code that produced output via a series of comma-separated values, rather than to use string formatting. This occurred on multiple occasions, suggesting the possibility that it might become a chronic problem. :blush: Fortunately, other participants in the MMOOC raised the bar by posting more Pythonic code. This reminded me that it only takes an additional minute to put in the necessary effort.

So, to celebrate, I plan to correct this problem by using string formatting next week.

But, since failure is a sure way to generate future success, I hope to fail in another respect next week, thereby setting the stage to make amends the following week. :smile: Any examples of how others have failed would be appreciated, as it would offer a menu of possibilities.

Does this failure party have any sympathetic people to check code and give feedback?

This is my 3rd attempt at rock, paper, scissors ( about 8 hours and counting…). I have checked it against the rps_example1.py, and apart from the order of the elements, appears identical to me, yet it keeps generating an error “invalid syntax” after the “elif (player1 ==“rock”…” line

def valid_input(input):
    if input=="rock" or input=="paper" or input == "scissors":
        return True
    else:
        return False


def rps(player1,player2):
    if valid_input(player1) and valid_input(player2):
        if player1==player2:
            return "this is a tie"
        elif (player1 =="rock" and player2 =="scissors")/
            or (player1 =="scissors" and player2 == "paper")/
            or (player1 =="paper" and player2 =="rock"):
            return "player 1 wins"
        else:
            return "player 2 wins"
    else:
        return  "Not a valid input"

#Test

    rps("rock", "paper")
    rps("stone","paper")
    rps("paper", "scissors")
    rps("paper", "rock")

hey @philgil. Seems like

elif (player1 =="rock" and player2 =="scissors")/
            or (player1 =="scissors" and player2 == "paper")/
            or (player1 =="paper" and player2 =="rock"):

should be

elif (player1 =="rock" and player2 =="scissors")\
            or (player1 =="scissors" and player2 == "paper")\
            or (player1 =="paper" and player2 =="rock"):

Just change the direction of the slash! In general a / is interpreted as a normal character while \ is interpreted as an escape character - iow doing something special with whatever character follows. In the case above \ is causing the python interpreter to ignore the new line.

1 Like

Thanks Dirk. Looks so obvious now :blush:
I was obviously looking at it for too long.

1 Like

Hi,

A year ago, when I started Tetris project I wrote without tests this line

return board.can_move(self.x + dx, self.y + dx)

It was in Block.move(dx, dy) method. It took me a while (and many prints) this week to find this bug.

Now I constantly see GraphicsError, when I try to exit gentle after “Game Over” and close window.

What OS are you using? I have been testing the code on Windows 7 and Mac OS, and am not getting that error upon closing the game board window.

Some of the participants in the current iteration of the Mechanical MOOC are working on 6.189 Final Project – Tetris! at this time. If you post code in the topic The Tetris Project, with all the indentation and underscores intact, we can look at it, try it out, and discuss any errors that get raised,

Win7 x64, but it was just a runtime error in my code.