[Tutor] more problems, my final questions
Danny Yoo
dyoo@hkn.eecs.berkeley.edu
Wed, 10 Jul 2002 00:27:23 -0700 (PDT)
Hi Kyle,
> New problems has arisin. I was wondering if there was way to replace:
> if begin in "Yy":
> print "why is the sky blue?"
>
> With something like:
> if begin == "Y" "y":
> print "why isn't the sky green or purple?"
By the way, the statement above translates to:
"if begin is equal to the string 'Yy', do this:..."
because if two literal strings are together like that, they'll stick
together. For example:
> I'm asking because I recently added:
> else begin in "CustomcustomCUSTOM":
I think that you're trying to find if there's a substring of begin within
that "CustomcustomCUSTOM" string. If so, there's another way of
expressing this:
###
def substring(word, sentence):
return sentence.find(word) != -1
###
>
> But I had also changed the Yy and Nn to be YyYesyesYES and NnNonoNO,
> however the o in No and the o and custom are conflicting and I'm trying
> to find a way to fix this. Any ideas?
>
> Also, my final questions regaurding this program:
> Could some one point me to an example or show me how to
> countdown/countup time.sleep?
> And the same goes for delaying/suspending and prematurly ending
> time.sleep.
>
> If anyone sees any problems-waiting-to-happen in my program (attached)
> please tell me.
>
> Thank you, this list has been so helpful.
> --
> Kyle
>
>
> _______________________________________________
> Tutor maillist - Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>