[Tutor] String method "strip()" not working

2015-03-07 Thread Akash Shekhar
I am trying to learn how to use strip() method. It is supposed to cut out all the whitespace as I read in the tutorial. But the code is not working. Here's my code: sentence = "Hello, how are you?" > > >> print(sentence) > > >> print(sentence.strip()) > > >> input("\n\nPress enter key to exit.")

Re: [Tutor] String method "strip()" not working

2015-03-07 Thread Alan Gauld
On 07/03/15 13:15, Akash Shekhar wrote: I am trying to learn how to use strip() method. It is supposed to cut out all the whitespace as I read in the tutorial. Read it again more closely. --- Help on built-in function strip: strip(...) S.strip([chars]) -> string or unicode

Re: [Tutor] String method "strip()" not working

2015-03-07 Thread Dave Angel
On 03/07/2015 08:15 AM, Akash Shekhar wrote: I am trying to learn how to use strip() method. It is supposed to cut out all the whitespace as I read in the tutorial. But the code is not working. Here's my code: sentence = "Hello, how are you?" print(sentence) print(sentence.strip())

Re: [Tutor] String method "strip()" not working

2015-03-07 Thread Mark Lawrence
On 07/03/2015 14:54, Alan Gauld wrote: On 07/03/15 13:15, Akash Shekhar wrote: I am trying to learn how to use strip() method. It is supposed to cut out all the whitespace as I read in the tutorial. Read it again more closely. --- Help on built-in function strip: strip(...)

Re: [Tutor] String method "strip()" not working

2015-03-07 Thread Alan Gauld
On 07/03/15 15:17, Mark Lawrence wrote: S.strip([chars]) -> string or unicode Return a copy of the string S with leading and trailing whitespace removed. If chars is given and not None, remove characters in chars instead. If chars is unicode, S will be converted to unic

[Tutor] Help

2015-03-07 Thread elie khairallah
hello , I would like to know if theres a way to change a variable's name after every iteration for example I want to make a function that stores a number in x_1 if i=1 and in x_2 if i=2. To be more precise: i=1 def f(n): while ihttps://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Help

2015-03-07 Thread Joel Goldstick
On Sat, Mar 7, 2015 at 10:39 AM, elie khairallah wrote: > hello , I would like to know if theres a way to change a variable's name > after every iteration for example I want to make a function that stores a > number in x_1 if i=1 and in x_2 if i=2. > To be more precise: > i=1 > def f(n): >

[Tutor] Daft subjects (Was Help)

2015-03-07 Thread Mark Lawrence
On 07/03/2015 15:39, elie khairallah wrote: hello , I would like to know if theres a way to change a variable's name after every iteration for example I want to make a function that stores a number in x_1 if i=1 and in x_2 if i=2. To be more precise: i=1 def f(n): while i Why bother? Wh

Re: [Tutor] Help

2015-03-07 Thread Joel Goldstick
On Sat, Mar 7, 2015 at 1:28 PM, Danny Yoo wrote: >> You could certainly use I as an index into a list called x. This >> doesn't look like a good idea though > > > Can you explain more what's problematic with a list? > > My best understanding so far of the problem is that the original > questioner

Re: [Tutor] Help

2015-03-07 Thread Danny Yoo
On Sat, Mar 7, 2015 at 7:39 AM, elie khairallah wrote: > hello , I would like to know if theres a way to change a variable's name > after every iteration for example I want to make a function that stores a > number in x_1 if i=1 and in x_2 if i=2. Conceptually, I think you're looking for a list.

Re: [Tutor] Help

2015-03-07 Thread Danny Yoo
> You could certainly use I as an index into a list called x. This > doesn't look like a good idea though Can you explain more what's problematic with a list? My best understanding so far of the problem is that the original questioner is trying to compute a tabulation of results. For example,

Re: [Tutor] Help

2015-03-07 Thread Alan Gauld
On 07/03/15 15:39, elie khairallah wrote: hello , I would like to know if theres a way to change a variable's name after every iteration for example I want to make a function that stores a number in x_1 if i=1 and in x_2 if i=2. To be more precise: i=1 def f(n): while i Others have alrea

Re: [Tutor] Help

2015-03-07 Thread Mark Lawrence
On 07/03/2015 19:04, Alan Gauld wrote: On 07/03/15 15:39, elie khairallah wrote: hello , I would like to know if theres a way to change a variable's name after every iteration for example I want to make a function that stores a number in x_1 if i=1 and in x_2 if i=2. To be more precise: i=1 def