On Monday, March 4, 2013 4:37:11 PM UTC, Ian wrote:
On Mon, Mar 4, 2013 at 7:34 AM, Bryan Devaney bryan.deva...@gmail.com wrote:
if character not in lettersGuessed:
return True
return False
assuming a function is being used to pass each letter of the
Hi all,
I'm super new to python, just fyi.
In the piece of code below, secretWord is a string and lettersGuessed is a
list. I'm trying to find out if ALL the characters of secretWord are included
in lettersGuessed, even if there are additional values in the lettersGuessed
list that aren't in
In fact this code is already doing what you want, but if the second
character, by example, is not in secrectWord it'll jump out of the for and
return. If you want that interact through the all characters and maybe
count how many them are in the secrectWord, just take of the return there
or do
On Mon, Mar 4, 2013 at 7:18 AM, newtopython roshen.set...@gmail.com wrote:
Hi all,
I'm super new to python, just fyi.
Welcome. Next time write a better subject line, and be sure the code you
post is actually the code you are running. Provide the results you want
and what you get. Provide
On 03/04/2013 07:18 AM, newtopython wrote:
Hi all,
I'm super new to python, just fyi.
Welcome to the Python list.
In the piece of code below, secretWord is a string and lettersGuessed is a
list. I'm trying to find out if ALL the characters of secretWord are included
in lettersGuessed,
if character not in lettersGuessed:
return True
return False
assuming a function is being used to pass each letter of the letters guessed
inside a loop itself that only continues checking if true is returned, then
that could work.
It is however more work than is needed.
On Monday, March 4, 2013 6:18:20 AM UTC-6, newtopython wrote:
[Note: Post has be logically re-arranged for your comprehensive pleasures]
for character in secretWord:
if character not in lettersGuessed:
return True
return False
What this code is doing is only checking the
On Mon, Mar 4, 2013 at 7:34 AM, Bryan Devaney bryan.deva...@gmail.com wrote:
if character not in lettersGuessed:
return True
return False
assuming a function is being used to pass each letter of the letters guessed
inside a loop itself that only continues checking if true
El 04/03/13 09:18, newtopython escribió:
Hi all,
I'm super new to python, just fyi.
In the piece of code below, secretWord is a string and lettersGuessed is a
list. I'm trying to find out if ALL the characters of secretWord are included
in lettersGuessed, even if there are additional values
On Friday, January 4, 2013 11:18:24 AM UTC+5:30, Steven D'Aprano wrote:
On Thu, 03 Jan 2013 12:04:03 -0800, subhabangalore wrote:
Dear Group,
If I take a list like the following:
fruits = ['banana', 'apple', 'mango']
for fruit in fruits:
print 'Current fruit :',
On Thu, 03 Jan 2013 12:04:03 -0800, subhabangalore wrote:
Dear Group,
If I take a list like the following:
fruits = ['banana', 'apple', 'mango']
for fruit in fruits:
print 'Current fruit :', fruit
Now,
if I want variables like var1,var2,var3 be assigned to them, we may
take,
Dear Group,
If I take a list like the following:
fruits = ['banana', 'apple', 'mango']
for fruit in fruits:
print 'Current fruit :', fruit
Now,
if I want variables like var1,var2,var3 be assigned to them, we may take,
var1=banana,
var2=apple,
var3=mango
but can we do something to
On 2013-01-03 20:04, subhabangal...@gmail.com wrote:
Dear Group,
If I take a list like the following:
fruits = ['banana', 'apple', 'mango']
for fruit in fruits:
print 'Current fruit :', fruit
Now,
if I want variables like var1,var2,var3 be assigned to them, we may take,
var1=banana,
subhabangal...@gmail.com wrote:
Dear Group,
If I take a list like the following:
fruits = ['banana', 'apple', 'mango']
for fruit in fruits:
print 'Current fruit :', fruit
Now,
if I want variables like var1,var2,var3 be assigned to them, we may take,
var1=banana,
var2=apple,
Yeah, this seems like a bad idea. What exactly are you trying to do here?
Maybe using a dictionary is what you want?
d = {
'first' : 'banana',
'second' : 'apple',
'third' : 'mango'
}
for key, value in d.items():
print key, value
However I'm still not sure why you'd want to
I'm interested to know why you're trying this as well. Is this something that
would be helped by creating a class and then dynamically creating instances of
that class? Something like...
class Fruit:
def __init__(self, name):
self.name = name
for fruit in ['banana', 'apple',
On Jan 4, 6:04 am, subhabangal...@gmail.com wrote:
but can we do something to assign the variables dynamically I was thinking
of
var_series=['var1','var2','var3']
for var in var_series:
for fruit in fruits:
print var,fruits
Before trying to do this, write the next bit of code where
On Thu, 03 Jan 2013 12:04:03 -0800, subhabangalore wrote:
Dear Group,
If I take a list like the following:
fruits = ['banana', 'apple', 'mango']
for fruit in fruits:
print 'Current fruit :', fruit
Now,
if I want variables like var1,var2,var3 be assigned to them, we may
take,
Hi all,
I am a very novice for Python. Currently, I am trying to read continuous
columns repeatedly in the form of array.
my code is like below:
import numpy as np
b = []
c = 4
f = open(text.file, r)
while c 10:
c = c + 1
for columns in ( raw.strip().split() for raw in f
Isaac Won winef...@gmail.com wrote:
while c 10:
c = c + 1
for columns in ( raw.strip().split() for raw in f ):
b.append(columns[c])
y = np.array(b, float)
print c, y
I thought that can get the arrays of the columns[5] to [10],
but I only could
On 31/12/12 11:02:56, Isaac Won wrote:
Hi all,
I am a very novice for Python. Currently, I am trying to read continuous
columns repeatedly in the form of array.
my code is like below:
import numpy as np
b = []
c = 4
f = open(text.file, r)
while c 10:
c = c + 1
On Monday, December 31, 2012 5:25:16 AM UTC-6, Gisle Vanem wrote:
Isaac Won winef...@gmail.com wrote:
while c 10:
c = c + 1
for columns in ( raw.strip().split() for raw in f ):
b.append(columns[c])
y = np.array(b,
On Monday, December 31, 2012 6:59:34 AM UTC-6, Hans Mulder wrote:
On 31/12/12 11:02:56, Isaac Won wrote:
Hi all,
I am a very novice for Python. Currently, I am trying to read continuous
columns repeatedly in the form of array.
my code is like below:
import numpy as np
jmDesktop [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
So what is n and x in the first iteration? Sorry. I'm trying.
Remember how Python's range operator works. range(n, x) constructs a list
that consists of all elements starting with n and up to, but /not
including/, x.
jmDesktop wrote:
[...]
So what is n and x in the first iteration? Sorry. I'm trying.
Somewhat feebly, if you don't mind my saying so, but don't worry.
The usual way to proceed in the face of such ignorance is to insert some
form of output that will tell you the answer to your question.
So:
From the Python.org tutorial:
for n in range(2, 10):
... for x in range(2, n):
... if n % x == 0:
... print n, 'equals', x, '*', n/x
... break
... else:
... # loop fell through without finding a factor
... print n, 'is a prime number'
...
2
jmDesktop schrieb:
From the Python.org tutorial:
for n in range(2, 10):
... for x in range(2, n):
... if n % x == 0:
... print n, 'equals', x, '*', n/x
... break
... else:
... # loop fell through without finding a factor
... print
-Original Message-
From: [EMAIL PROTECTED] [mailto:python-
[EMAIL PROTECTED] On Behalf Of jmDesktop
Sent: Wednesday, April 09, 2008 4:51 PM
To: python-list@python.org
Subject: basic python question about for loop
From the Python.org tutorial:
for n in range(2, 10
jmDesktop wrote:
From the Python.org tutorial:
for n in range(2, 10):
... for x in range(2, n):
... if n % x == 0:
... print n, 'equals', x, '*', n/x
... break
... else:
... # loop fell through without finding a factor
... print n,
On Apr 9, 4:58 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote:
jmDesktop schrieb:
From the Python.org tutorial:
for n in range(2, 10):
... for x in range(2, n):
... if n % x == 0:
... print n, 'equals', x, '*', n/x
... break
... else:
On Apr 9, 4:59 pm, Reedick, Andrew [EMAIL PROTECTED] wrote:
-Original Message-
From: [EMAIL PROTECTED] [mailto:python-
[EMAIL PROTECTED] On Behalf Of jmDesktop
Sent: Wednesday, April 09, 2008 4:51 PM
To: [EMAIL PROTECTED]
Subject: basic python question about for loop
From
-Original Message-
From: [EMAIL PROTECTED] [mailto:python-
[EMAIL PROTECTED] On Behalf Of jmDesktop
Sent: Wednesday, April 09, 2008 5:04 PM
To: python-list@python.org
Subject: Re: basic python question about for loop
for n in range(2, 10):
... for x in range(2, n
jmDesktop schrieb:
On Apr 9, 4:58 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote:
jmDesktop schrieb:
From the Python.org tutorial:
for n in range(2, 10):
... for x in range(2, n):
... if n % x == 0:
... print n, 'equals', x, '*', n/x
... break
...
|So what is n and x in the first iteration? Sorry. I'm trying.
When n == 2, the inner loop executes 0 times (the length of range(2,n)) and
then falls thru to the else clause, printing the correct answer.
--
http://mail.python.org/mailman/listinfo/python-list
Hi,
I noticed that the 'for' loop can be used inline with a list definition. For
example:
print [i for i in mylist]
My first question is what is the name for this? I couldn't find this usage
in the python docs; I only managed to learn about it through code samples on
the internet.
Secondly,
Robert Dailey wrote:
Hi,
I noticed that the 'for' loop can be used inline with a list definition.
For example:
print [i for i in mylist]
My first question is what is the name for this? I couldn't find this
usage in the python docs; I only managed to learn about it through code
On Fri, 2007-08-17 at 17:45 -0500, Robert Dailey wrote:
[...]
Secondly, I'm wondering how I can use this method of a for loop to
append strings to strings in a list. For example:
mylist = [
Hello ,
Hello again
]
I should be able to do this:
print [ i + World for i in mylist ]
37 matches
Mail list logo