문제

I'm trying to write a "game"where the user enters a move and the "cpu player" outputs its response, after which the user enters another move and so on. E.g.

$ enter a move #cpu prompt

5 #user's input

7 #cpu output

10 #user's input

16 #cpu output

20 #user's input

You win! #cpu's output

$

I know how sys.argv provides a list of arguments on the command line, but what would I use so that my program reads each input line and outputs a value to which the user inputs another argument?

Any help would be greatly appreciated

도움이 되었습니까?

해결책

Take a look at the raw_input() function built into Python. That should do exactly what you like.

playermove=raw_input()
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top