Simple question

W

wasian_god

yea im knew to python, and i kno this is a very simple question. im
trying to make a shell dat first says I want a cookie. Then it waits
for the user to input the word cookie. while cookie is not inputted
a timer counts down and at the end it prints out I want a cookie
again. The timer then gets shorter. Heres what i have so far...

print "I want a cookie!"

m = 10
y = m
gave = 0

if y == 0:
print "I want a cookie!"
m = m-1
y = m

if gave == 1:
print "Thank you! That is much better."
else:
y = y-1

I have tried a lot of other stuff so dont think this is what i
started out with. but this is what i have now, any help would be
appreciated so i can start gettin this whole "programming" stuff
down.
 
S

Sean Ross

Giving you the code to solve your problem wouldn't be of much benefit, but
the following should be enough:

you'll want to have a patience threshold (you'll ask for a cookie this many
times before demanding one)
you'll also need to keep track of the number of times you've asked for a
cookie
now you can use an infinite loop to
ask for a cookie and get the response (e.g., "May I have a cookie?",
"No")
remember to keep track of the number of times you've asked
if the response is 'cookie' (or 'yes', or whatever) then break out of
the loop and say thanks
otherwise, if the number of times you've asked has reached your patience
threshold then
demand a cookie(e.g., "I want a cookie!"),
become less patient (but avoid negative patience!),
and start a fresh round of asking
and your done.

HTH,
Sean
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,661
Latest member
sxarexu

Latest Threads

Top