Feb-17-2018, 03:34 PM
Hi all,
I'm going through an online course to learn Python3. Am getting on fine but I seem interested in finding not simply a "correct" answer that the site will parse and accept, I seem interested in thinking about the most efficient ways to solve any particular problem.
My current task is to code a simple game of "rock, paper, scissors". I'd like to achieve this by, in the second part of my code, taking inputs from both players, store them as variables (input1, input2), and then use an
It seems that if I write
I'm going through an online course to learn Python3. Am getting on fine but I seem interested in finding not simply a "correct" answer that the site will parse and accept, I seem interested in thinking about the most efficient ways to solve any particular problem.
My current task is to code a simple game of "rock, paper, scissors". I'd like to achieve this by, in the second part of my code, taking inputs from both players, store them as variables (input1, input2), and then use an
if:
test to find the winner. Seems sound in principle but what I do not know and do not know if it's possible is the following:It seems that if I write
"Rock > "Scissors"
... "Paper" > "Rock"
and so on, to have the If:
f statement evaluate each input and calculate the winner correctly in fact Python simply returns boolean values for these statements irrespective of my declarations. Is there a simple method of declaring these strings in some way that I can then state e.g. "This" > "That"
, or is this simply not possible? I realise there are other ways to solve the problem, but curious about whether the above approach could be made to work.