I wanted the program to stop only after all the letters were typed; why in the
world would I try to write a program with blanks for each letter that seem
intended to be filled, only to have it stop if the last letter is typed, or
have to type each letter so many times until its processed? If you
I wanted the program to stop only after all the letters were typed; why in the
world would I try to write a program with blanks for each letter that seem
intended to be filled, only to have it stop if the last letter is typed, or
have to type each letter so many times until its processed? If you
Thanks. I am running into a bunch of problems with the following code, all of
which are clear when running the program
import random
letters='abcdefg'
blanks='_'*len(letters)
print('type letters from a to g')
print(blanks)
for i in range(len(letters)):
if letters[i] in input():
bla
Is there also a way to have the code remember what I typed and not stop after
the first letter the user types? For example, if I typed 'a' once, thus
returning 'a__', and then typed in 'b', I want the code to return 'ab_'
and so on. I wasn't clear about this part in my original post. Tha
I'm trying to replace the blank(_) with the letter typed in by the user, in the
appropriate blank(_) spot where the letter should be (where is in the letters
list).
letters='abcdefg'
blanks='_ '*len(letters)
print('type letter from a to g')
print(blanks)
input1=input()
for i in range(len(letters
It's obvious that the word 'without' in my first sentence was meant to be
ommited, and it's a simple question. Thank Gary!
--
http://mail.python.org/mailman/listinfo/python-list
How can I use the '.split()' method (am I right in calling it a method?)
without instead of writing each comma between words in the pie list in the
following code? Also, is there a way to use .split instead of typing the
apostrophes? Thank you.
import random
pie=['keylime', 'peach', 'apple', 'c
I'm sorry, but I still don't understand how it applies to my problem. Thanks
for everyone's patience.
--
http://mail.python.org/mailman/listinfo/python-list
(I forgot to post this with my last post.)
Also, I don't understand any part of the following example, so there's no
specific line that's confusing me. Thanks for the help btw.
var = 42
def myfunc():
var = 90
print "before:", var
myfunc()
print "after:", var
def myfunc():
globa
(I forgot to post this with my last post.)
Also, I don't understand any part of the following example, so there's no
specific line that's confusing me. Thanks for the help btw.
var = 42
def myfunc():
var = 90
print "before:", var
myfunc()
print "after:", var
def myfunc():
glo
What does global mean?
--
http://mail.python.org/mailman/listinfo/python-list
Thanks, though me not utilizing any of the other advice wasn't from lack of
trying; I couldn't understand any of it. I get it now that I have a corrrect
example code in front of me.
--
http://mail.python.org/mailman/listinfo/python-list
I don't understand any of the advice any of you have given.
--
http://mail.python.org/mailman/listinfo/python-list
This is what I ended up with btw. Does this insult anyone's more well attuned
Python sensibilities?
letters='abcdefghijkl'
def repeat():
print('wanna go again?')
batman=input()
if batman in ('y','yes'):
main()
else:
return
def main():
print('guess a letter')
This is what I ended up with btw. Does this insult anyone's more well-attuned
Pythonic sensibilities?
letters='abcdefghijkl'
def repeat():
print('wanna go again?')
batman=input()
if batman in ('y','yes'):
main()
else:
return
def main():
print('guess a
What I wanted to happen is when the user typed something other than 'y' or
'yes' after being asked 'go again?', the batman==False line would cause the
program to stop asking anything and say 'this is the end'. Instead, what is
happening is that the program just keeps going. I figured that after
I'm trying to create an option for the program to repeat if the user types 'y'
or 'yes', using true and false values, or otherwise end the program. If anyone
could explain to me how to get this code working, I'd appreciate it.
letters='abcdefghijklmn'
batman=True
def thingy():
print('type le
Thanks that helped a lot!
--
http://mail.python.org/mailman/listinfo/python-list
Why won't the 'goodbye' part of this code work right? it prints 'ok' no matter
what is typed. Much thanks.
def thing():
print('go again?')
goagain=input()
if goagain=='y' or 'yes':
print('ok')
elif goagain!='y' or 'yes':
print('goodbye')
sys.exit()
thing()
Thanks I get it now.
--
http://mail.python.org/mailman/listinfo/python-list
I'm on chapter 9 of this guide to python:
http://inventwithpython.com/chapter9.html but I don't quite understand why
line 79 is what it is (blanks = blanks[:i] + secretWord[i] + blanks[i+1:]). I
particularly don't get the [i+1:] part. Any additional information and help
would be greatly ap
Thanks!
--
http://mail.python.org/mailman/listinfo/python-list
pie='apple keylime pecan meat pot cherry'
pie.split()
How can I print a word from the list other than this way: print(pie[0:5]) ?
Thanks in advance.
--
http://mail.python.org/mailman/listinfo/python-list
No.
--
http://mail.python.org/mailman/listinfo/python-list
How do I make it so I only have to type in 'parry' once?
import random
words=['hemisses', 'hestabsyou']
randomizer=random.choice(words)
if input()!=('duck', 'parry'):
print('try again')
if input()=='duck':
print(randomizer)
if randomizer=='hemisses':
results=['you should have r
Thanks everyone!
--
http://mail.python.org/mailman/listinfo/python-list
Is there a more efficient way of doing this? Any help is gratly appreciated.
import random
def partdeux():
print('''A man lunges at you with a knife!
Do you DUCK or PARRY?''')
option1=('duck')
option2=('parry')
optionsindex=[option1, option2]
randomizer=random.choice(optionsin
How do I make the following program repeat twice instead of asking whether the
player wants to play again?
import random
import time
def intro():
print('You spot 2 caves in the distance.')
print ('You near 2 cave entrances..')
time.sleep(1)
print('You proceed even nearer...')
How do I make the following program play the 'guess the number game' twice?
import random
guessesTaken = 0
print('Hello! What is your name?')
myName = input()
number = random.randint(1, 20)
print('Well, ' + myName + ', I am thinking of a number between 1 and 20.')
while guessesTaken < 6:
print
If you get the time, please post an example, because I don't understand.
--
http://mail.python.org/mailman/listinfo/python-list
The 2 makes the game play twice instead of 3 times, right? I've tried it with
the 1, but but I'm still having trouble. Again, to be exact, I want to somehow
make it count down from 2 (the number of games)and print. If that's what this
does, is it possible to insert it into my original main progr
How do I make it say that I have one game left? I'm having trouble fitting it
into my main code. Thanks a lot for the help btw.
--
http://mail.python.org/mailman/listinfo/python-list
(Didn't mean to post the last bit.) Is this possibly what you meant? If it is I
still can't figure out how to apply it to the guessthenumber program.
numberofgames=1
while numberofgames<4:
numberofgames=numberofgames+2
print (4-numberofgames)
if numberofguesses>3:
print(numb
On Wednesday, April 10, 2013 5:39:23 AM UTC-4, eschne...@comcast.net wrote:
> Could anyone tell me how to make the program tell me how many games are left
> before the first game and second game? For example, after one game of guess
> the number, I want it to tell me that i get one more game. P.S
On Wednesday, April 10, 2013 5:44:20 AM UTC-4, Chris Angelico wrote:
> On Wed, Apr 10, 2013 at 7:39 PM, wrote:
>
> > Could anyone tell me how to make the program tell me how many games are
> > left before the first game and second game? For example, after one game of
> > guess the number, I wa
Could anyone tell me how to make the program tell me how many games are left
before the first game and second game? For example, after one game of guess the
number, I want it to tell me that i get one more game. P.S. I'm totally new to
python (obviously), and I just added numberofgames variable
36 matches
Mail list logo