[Tutor] I am trying to print list elements but i am getting 'none'

2011-10-10 Thread Praveen Singh
This is my code- def getNumbers(num): myList=[] for numbers in range(0,num,2): print myList.append(numbers) output- >>> getNumbers(10) None None None None None Then i find out that list.append doesn't return anything.Then what should i use for this kind of operation.but if i d

Re: [Tutor] I am trying to print list elements but i am getting 'none'

2011-10-10 Thread Nitin Pawar
Try giving the print statement outside the for loop On Mon, Oct 10, 2011 at 6:56 PM, Praveen Singh wrote: > This is my code- > def getNumbers(num): > myList=[] > for numbers in range(0,num,2): > print myList.append(numbers) > > > output- > >>> getNumbers(10) > None > None > Non

Re: [Tutor] I am trying to print list elements but i am getting 'none'

2011-10-10 Thread Christian Witts
On 2011/10/10 03:26 PM, Praveen Singh wrote: This is my code- def getNumbers(num): myList=[] for numbers in range(0,num,2): print myList.append(numbers) output- >>> getNumbers(10) None None None None None Then i find out that list.append doesn't return anything.Then what sh

Re: [Tutor] I am trying to print list elements but i am getting 'none'

2011-10-10 Thread Steven D'Aprano
Praveen Singh wrote: This is my code- def getNumbers(num): myList=[] for numbers in range(0,num,2): print myList.append(numbers) output- getNumbers(10) None None None None None Then i find out that list.append doesn't return anything.Then what should i use for this kind of

Re: [Tutor] I am trying to print list elements but i am getting 'none'

2011-10-10 Thread Wayne Werner
On Mon, Oct 10, 2011 at 8:26 AM, Praveen Singh wrote: > print myList.append(numbers) Your problem is with that statement. >>> mylist = [] >>> x = mylist.append(3) >>> x >>> x is None True >>> help(mylist.append) Help on built-in function append: append(...) L.append(object) -- append objec

Re: [Tutor] I am trying to print list elements but i am getting 'none'

2011-10-10 Thread Bod Soutar
On 10 October 2011 14:26, Praveen Singh wrote: > This is my code- >  def getNumbers(num): >     myList=[] >     for numbers in range(0,num,2): >   print myList.append(numbers) > > > output- getNumbers(10) > None > None > None > None > None > > Then i find out that list.append doesn't

[Tutor] help

2011-10-10 Thread George Nyoro
; print myList.append(numbers) > > > output- >>>> getNumbers(10) > None > None > None > None > None > > Then i find out that list.append doesn't return anything.Then what should i > use for this kind of operation.but if i do something like

Re: [Tutor] swapping list elements based on some criterion

2011-10-10 Thread Wayne Werner
2011/10/7 Emad Nawfal (عمـ نوفل ـاد) > I want to re-structure English so that the adjectives appear after the > nouns, instead of before. > If I have a sentence like: > > The tall man plays well > I need to change it to > The man tall plays well > Others have offered plenty of help, though I not

Re: [Tutor] help

2011-10-10 Thread Alan Gauld
On 10/10/11 20:23, George Nyoro wrote: On 10/10/2011, tutor-requ...@python.org wrote: Send Tutor mailing list submissions to tutor@python.org To subscribe or unsubscribe via the World Wide Web, visit snip >> When replying, please edit your Subject line so it is more specifi

[Tutor] Finding if a passed variable is within to set parameters

2011-10-10 Thread Mike Nickey
Hey all, I'm trying to write a def that has a check to see if the entered information is within a pre-determined valid set. Below is what I have so far but it doesn't seem to be working properly. What I want is to have the user be able to enter 1 through 8 and have the information pass fine but

Re: [Tutor] swapping list elements based on some criterion

2011-10-10 Thread Steven D'Aprano
Wayne Werner wrote: 2011/10/7 Emad Nawfal (عمـ نوفل ـاد) I want to re-structure English so that the adjectives appear after the nouns, instead of before. If I have a sentence like: The tall man plays well I need to change it to The man tall plays well Others have offered plenty of help, th

Re: [Tutor] Finding if a passed variable is within to set parameters

2011-10-10 Thread Marc Tompkins
On Mon, Oct 10, 2011 at 3:13 PM, Mike Nickey wrote: > Hey all, > > I'm trying to write a def that has a check to see if the entered > information is within a pre-determined valid set. > Below is what I have so far but it doesn't seem to be working properly. > What I want is to have the user be ab

Re: [Tutor] Finding if a passed variable is within to set parameters

2011-10-10 Thread Steven D'Aprano
Mike Nickey wrote: Hey all, I'm trying to write a def that has a check to see if the entered information is within a pre-determined valid set. Below is what I have so far but it doesn't seem to be working properly. What I want is to have the user be able to enter 1 through 8 and have the inform

Re: [Tutor] Finding if a passed variable is within to set parameters

2011-10-10 Thread Alan Gauld
On 10/10/11 23:13, Mike Nickey wrote: What I want is to have the user be able to enter 1 through 8 and have the information pass fine but anything else would cause the user to repeat the process. if not (1 <= value <= 8): # handle error else: # carry on as planned I'm using a while loop

Re: [Tutor] String switch

2011-10-10 Thread Christopher King
Okay, there is a python file called target.py. In the same directory there is a file named main.py. You are the author of main.py. The code in main.py will write to target.py. Then the antivirus catches main.py and removes, but not the modification to target.py. Main.py can not create new files. Wh

Re: [Tutor] String switch

2011-10-10 Thread Steven D'Aprano
Christopher King wrote: Okay, there is a python file called target.py. In the same directory there is a file named main.py. You are the author of main.py. The code in main.py will write to target.py. Then the antivirus catches main.py and removes, but not the modification to target.py. Main.py ca

Re: [Tutor] String switch

2011-10-10 Thread Dave Angel
On 10/10/2011 08:56 PM, Christopher King wrote: Okay, there is a python file called target.py. In the same directory there is a file named main.py. You are the author of main.py. The code in main.py will write to target.py. Then the antivirus catches main.py and removes, but not the modification