Beginner question
Peter Otten
__peter__ at web.de
Tue Jun 4 05:23:22 EDT 2013
Chris Angelico wrote:
> On Tue, Jun 4, 2013 at 5:57 PM, John Ladasky <john_ladasky at sbcglobal.net>
> wrote:
>> On Tuesday, June 4, 2013 12:45:38 AM UTC-7, Anssi Saari wrote:
>>
>>> BTW, did I get the logic correctly, the end result is random?
>>
>> You're right! I'm guessing that's not what the OP wants?
>
> I'm guessing that's exactly what the OP wants. This is a fairly
> classic programming puzzle; on the surface it appears that you have
> some influence on the outcome, but ultimately you're playing
> rock-paper-scissors with the Random Number God.
As it is written, don't you always win if you hit enter?
It may be the approved cheat code, though...
OP:
("some string")
is not a tuple, it is the same as just
"some string"
therefore
option1 = "some string"
if input() in option1:
print("yes")
prints 'yes' if the user types in a substring of option1, and the shortest
substring of any string is "".
For a single-item tuple the trailing comma is mandatory:
>>> ("some string") # string
'some string'
>>> "some string", # tuple
('some string',)
>>> ("some string",) # tuple, parens added for clarity
('some string',)
In general a tuple is consituted by the comma(s), not the parentheses:
>>> "one", "two"
('one', 'two')
More information about the Python-list
mailing list