Re: Question on for loop

2013-03-05 Thread Bryan Devaney
On Monday, March 4, 2013 4:37:11 PM UTC, Ian wrote: > On Mon, Mar 4, 2013 at 7:34 AM, Bryan Devaney wrote: > > >> if character not in lettersGuessed: > > >> > > >> return True > > >> > > >> return False > > > > > > assuming a function is being used to pass each letter of the

Re: Question on for loop

2013-03-04 Thread Ricardo Aráoz
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 i

Re: Question on for loop

2013-03-04 Thread Ian Kelly
On Mon, Mar 4, 2013 at 7:34 AM, Bryan Devaney 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 is returned

Re: Question on for loop

2013-03-04 Thread Rick Johnson
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

Re: Question on for loop

2013-03-04 Thread Bryan Devaney
> 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 need

Re: Question on for loop

2013-03-04 Thread Dave Angel
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, eve

Re: Question on for loop

2013-03-04 Thread Joel Goldstick
On Mon, Mar 4, 2013 at 7:18 AM, newtopython 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 the traceback if the

Re: Question on for loop

2013-03-04 Thread leo kirotawa
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 some

Question on for loop

2013-03-04 Thread newtopython
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 s

Re: Question on for loop

2013-01-15 Thread subhabangalore
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

Re: Question on for loop

2013-01-04 Thread Alister
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 > ta

Re: Question on for loop

2013-01-03 Thread Steven D'Aprano
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 > t

Re: Question on for loop

2013-01-03 Thread alex23
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

Re: Question on for loop

2013-01-03 Thread Don Ross
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', 'mang

Re: Question on for loop

2013-01-03 Thread Matt Jones
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 d

Re: Question on for loop

2013-01-03 Thread Peter Otten
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=ap

Re: Question on for loop

2013-01-03 Thread MRAB
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, var2=a

Question on for loop

2013-01-03 Thread subhabangalore
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 as