Rock Paper Scissors Program Not Working (Python)

前端 未结 2 1475
感情败类
感情败类 2021-01-07 01:07

Problems: Program does not seem to accept the integers entered. Won\'t add to win/loss/draw count and does not display computer choice in debug mode

2条回答
  •  失恋的感觉
    2021-01-07 02:01

    I'm no Pythonista, but at a guess, input returns strings, and you'll need to convert to integer before comparing to the computer's int.

    I also think you are missing a trick in DRYing up your code - you should be able to have a single playgame method, which takes an additional boolean parameter debugmode, which instead of calling print directly, calls an indirection, e.g.:

    def debugPrint(debugString, debugMode)
         if debugMode
             print(debugString)
    

    Hope this makes sense?

提交回复
热议问题