Re: [Tutor] Strings

2014-11-06 Thread William Becerra
Thank you guys On Thu, Nov 6, 2014 at 3:39 AM, Dave Angel wrote: > William Becerra Wrote in message: > > > > have the following code: > names = "John, Cindy, Peter" > def find(str, ch, s): > index = 0 > while index < len(str): > if s==1: > for char in names[:4]: >

Re: [Tutor] Strings

2014-11-05 Thread Dave Angel
William Becerra Wrote in message: > have the following code: names = "John, Cindy, Peter" def find(str, ch, s): index = 0 while index < len(str): if s==1: for char in names[:4]: if str[index] == ch: return index + 1

Re: [Tutor] Strings

2014-11-05 Thread Peter Otten
William Becerra wrote: > Hey, I'm new to programming > running Python 2.7.8 Windows 8.1 > I was reading 'How to Think Like a Computer Scientist- Learning with > Python' chapter 7 sub-chapter 7.7 > > I have the following code: > names = "John, Cindy, Peter" > def find(str, ch, s): > index = 0

Re: [Tutor] Strings

2014-11-05 Thread Alan Gauld
On 05/11/14 13:19, William Becerra wrote: names = "John, Cindy, Peter" def find(str, ch, s): index = 0 while index < len(str): if s==1: for char in names[:4]: if str[index] == ch: return index + 1 index = inde

[Tutor] Strings

2014-11-05 Thread William Becerra
Hey, I'm new to programming running Python 2.7.8 Windows 8.1 I was reading 'How to Think Like a Computer Scientist- Learning with Python' chapter 7 sub-chapter 7.7 I have the following code: names = "John, Cindy, Peter" def find(str, ch, s): index = 0 while index < len(str): if s==

Re: [Tutor] Strings.

2012-10-26 Thread David Hutto
On Tue, Oct 23, 2012 at 7:48 PM, Alexander wrote: > On Tue, Oct 23, 2012 at 7:24 PM, Nitin Ainani wrote: >> Dear Sir/Madam, >> >> I am new to python I have a question. It is as follows: >> >> Suppose s is a variable and s stores empty string >> >> emptyString = "" > #consider the string to be no

Re: [Tutor] Strings.

2012-10-23 Thread Mark Lawrence
On 24/10/2012 00:24, Nitin Ainani wrote: Dear Sir/Madam, I am new to python I have a question. It is as follows: Suppose *s* is a variable and *s* stores empty string Pythonistas prefer the use of name and not variable. s="" Now if we write following statement print(s[0]) # it give

Re: [Tutor] Strings.

2012-10-23 Thread Dave Angel
On 10/23/2012 07:48 PM, Alexander wrote: > On Tue, Oct 23, 2012 at 7:24 PM, Nitin Ainani wrote: >> Dear Sir/Madam, >> >> I am new to python I have a question. It is as follows: >> >> Suppose s is a variable and s stores empty string >> >> emptyString = "" > #consider the string to be non-empty, t

Re: [Tutor] Strings.

2012-10-23 Thread Alexander
On Tue, Oct 23, 2012 at 7:24 PM, Nitin Ainani wrote: > Dear Sir/Madam, > > I am new to python I have a question. It is as follows: > > Suppose s is a variable and s stores empty string > > emptyString = "" #consider the string to be non-empty, that is, let's say 13 characters long (the number you

[Tutor] Strings.

2012-10-23 Thread Nitin Ainani
Dear Sir/Madam, I am new to python I have a question. It is as follows: Suppose *s* is a variable and *s* stores empty string s="" Now if we write following statement print(s[0]) # it gives error print(s[0:])# it does not give error print (s[13:13]) # this too does not give erro

Re: [Tutor] strings and replace

2009-09-16 Thread Kent Johnson
On Wed, Sep 16, 2009 at 10:33 AM, Jojo Mwebaze wrote: > Hello There Again > > Might be a silly question but it has played me for the last two days! > > I have a string 'mystring' (pasted below), what i want  to do is to change > the values of  of NAXIS1 (=1024)  and NAXIS2 (=2048) to some other va

[Tutor] strings and replace

2009-09-16 Thread Jojo Mwebaze
Hello There Again Might be a silly question but it has played me for the last two days! I have a string 'mystring' (pasted below), what i want to do is to change the values of of NAXIS1 (=1024) and NAXIS2 (=2048) to some other values! say NAXIS1 = 999 and NAXIS2 = 888. These old values that i

Re: [Tutor] strings using Czech language characters

2009-05-24 Thread vy
[ wish to make a dictionary of english to czech words / Unsupported characters in input / ISO-8859-2 ] have a look at the manual, in my case, section 4.9.2 on stand encodings p. 149 of the 2.4.3 (lib.pdf) Python Library Reference and at the python prompt try >>> help('modules codecs') -- vy ___

Re: [Tutor] strings using Czech language characters

2009-05-24 Thread Kent Johnson
On Sat, May 23, 2009 at 11:31 PM, Leon Williams wrote: > Hello, > > I wish to make a dictionary of english to czech words.  I thought I would > first see if python will print a czech character.  I used the example in the > tutorial (it uses a euro symbol, and a different iso character set so I > c

[Tutor] strings using Czech language characters

2009-05-23 Thread Leon Williams
Hello,   I wish to make a dictionary of english to czech words.  I thought I would first see if python will print a czech character.  I used the example in the tutorial (it uses a euro symbol, and a different iso character set so I changed mine to include a character set that includes eastern eu

Re: [Tutor] strings and int()

2009-01-15 Thread Andre Engels
On Thu, Jan 15, 2009 at 1:14 AM, Mr Gerard Kelly wrote: > If you have a string "6", and you do int("6"), you get the number 6. > > But if you have a string "2*3" and you do int("2*3") you get a name error. > > How do you take an expression in a string, and evaluate the expression > to get a number

Re: [Tutor] strings and int()

2009-01-14 Thread wesley chun
> If you have a string "6", and you do int("6"), you get the number 6. > But if you have a string "2*3" and you do int("2*3") you get a name error. the reason you get this error is because "2*3" is not a string representation of an integer whereas "6" is. in other words 2*3 is not a number. > Ho

Re: [Tutor] strings and int()

2009-01-14 Thread jadrifter
Try eval("2*3") On Thu, 2009-01-15 at 10:14 +1000, Mr Gerard Kelly wrote: > If you have a string "6", and you do int("6"), you get the number 6. > > But if you have a string "2*3" and you do int("2*3") you get a name error. > > How do you take an expression in a string, and evaluate the expressi

[Tutor] strings and int()

2009-01-14 Thread Mr Gerard Kelly
If you have a string "6", and you do int("6"), you get the number 6. But if you have a string "2*3" and you do int("2*3") you get a name error. How do you take an expression in a string, and evaluate the expression to get a number? I want to be able to turn the string "2*3" into the number 6. t

Re: [Tutor] strings & splitting

2006-01-25 Thread Kent Johnson
Liam Clarke wrote: > Hi, > > Thanks Kent, I'll check out the CSV module. I had a go with Pyparsing > awhile ago, and it's clocking in at the 3 minute mark also. > > Alan - the data is of the form - > > a = { > b = 1 > c = 2 > d = { e = { f = 4 g = "Ultimate Showdown of Ultimate Destiny" } h =

Re: [Tutor] strings & splitting

2006-01-25 Thread Alan Gauld
Liam wrote: Alan - the data is of the form - a = { b = 1 c = 2 d = { e = { f = 4 g = "Ultimate Showdown of Ultimate Destiny" } h = { i j k } } } Everything is whitespace delimited. I'd like to turn it into ["a", "=", "{", "b", "=", "1", "c", "=", "2", "d", "=", "{",

Re: [Tutor] strings & splitting

2006-01-25 Thread Liam Clarke
6, Alan Gauld <[EMAIL PROTECTED]> wrote: > Hi Liam, > > I'm not sure I really understand what you are trying > to get to here. > > Can you provide a short sample of before/after data > so we can see what we are trying to achieve? > > Alan G > > - Or

Re: [Tutor] strings & splitting

2006-01-25 Thread Alan Gauld
on Tutor" Sent: Wednesday, January 25, 2006 1:18 PM Subject: [Tutor] strings & splitting Hi all, I have a large string which I'm attempting to manipulate, which I find very convenient to call large_string.split(" ") on to conveniently tokenise. Except, however for the dou

Re: [Tutor] strings & splitting

2006-01-25 Thread Kent Johnson
Liam Clarke wrote: > Hi all, > > I have a large string which I'm attempting to manipulate, which I find > very convenient to call > large_string.split(" ") on to conveniently tokenise. > > Except, however for the double quoted strings within my string, which > contain spaces. > > At the moment I

[Tutor] strings & splitting

2006-01-25 Thread Liam Clarke
Hi all, I have a large string which I'm attempting to manipulate, which I find very convenient to call large_string.split(" ") on to conveniently tokenise. Except, however for the double quoted strings within my string, which contain spaces. At the moment I'm doing a split by \n, and then loopin

Re: [Tutor] Strings backwards

2006-01-18 Thread Danny Yoo
On Thu, 19 Jan 2006, Hans Dushanthakumar wrote: > Try this: > > print word[::-1] Hi Hans and Adam, Just wanted to point out: next time, let's try to figure out why Ryan had problems with this, rather than directly give a working answer. For example, we can ask things like: what part did Ryan

Re: [Tutor] Strings backwards

2006-01-18 Thread Adam
On 18/01/06, ryan luna <[EMAIL PROTECTED]> wrote: --- Adam <[EMAIL PROTECTED]> wrote:> On 18/01/06, ryan luna <[EMAIL PROTECTED]>> wrote: > >> > Hello, what i need to do is get user input and> then> > print the string backwards ^^ i have no idea how> to do> > that,> >> > print "Enter a word and i w

Re: [Tutor] Strings backwards

2006-01-18 Thread Hans Dushanthakumar
Try this: print word[::-1] -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of ryan luna Sent: Thursday, 19 January 2006 12:13 p.m. To: tutor@python.org Subject: [Tutor] Strings backwards Hello, what i need to do is get user input and then print the string

[Tutor] Strings backwards

2006-01-18 Thread ryan luna
Hello, what i need to do is get user input and then print the string backwards ^^ i have no idea how to do that, print "Enter a word and i well tell you how to say it backwards" word = raw_input("Your word: ") print word all that is simple enough im sure printing it out backwards is to, just d