Domanda

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

È stato utile?

Soluzione

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

playermove=raw_input()
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top