Re: Python solve problem with string operation

2014-01-16 Thread Asaf Las
inpu = "3443331123377" tstr = inpu[0] for k in range(1, len(inpu)): if inpu[k] != inpu[k-1] : tstr = tstr + inpu[k] print(tstr) -- https://mail.python.org/mailman/listinfo/python-list

Re: Python solve problem with string operation

2014-01-16 Thread Rhodri James
On Thu, 16 Jan 2014 22:24:40 -, Nac Temha wrote: Hi everyone, I want to do operation with chars in the given string. Actually I want to grouping the same chars. For example; input : "3443331123377" operation-> (3)(44)()(333)(11)(2)(33)(77) output: "34131237" How can I

Re: Python solve problem with string operation

2014-01-16 Thread giacomo boffi
giacomo boffi writes: > % python a.py > 34131237 % cat a.py i="3443331123377";n=0 while n+1!=len(i):i,n=(i[:n]+i[n+1:],n) if i[n+1]==i[n] else (i,n+1) print i % python a.py 34131237 % -- for Nikos -- https://mail.python.org/mailman/listinfo/python-list

Re: Python solve problem with string operation

2014-01-16 Thread Denis McMahon
On Fri, 17 Jan 2014 00:24:40 +0200, Nac Temha wrote: > Hi everyone, > > I want to do operation with chars in the given string. Actually I want > to grouping the same chars. > > For example; > > input : "3443331123377" > operation-> (3)(44)()(333)(11)(2)(33)(77) > output: "341312

Re: Python solve problem with string operation

2014-01-16 Thread giacomo boffi
Nac Temha writes: > Hi everyone, > > I want to do operation with chars in the given string. Actually I want to > grouping the same chars. > > For example; > > input : "3443331123377" > operation-> (3)(44)()(333)(11)(2)(33)(77) > output: "34131237" > > > > How can I do without list

Re: Python solve problem with string operation

2014-01-16 Thread John Gordon
In Mark Lawrence writes: > > input = "3443331123377" > > output = [] > > previous_ch = None > > for ch in input: > > if ch != previous_ch: > > output.append(ch) > > previous_ch = ch > > print ''.join(output) > > > Cheat, you've used a list :) Ack! I missed that

Re: Python solve problem with string operation

2014-01-16 Thread Mark Lawrence
On 16/01/2014 22:30, John Gordon wrote: In Nac Temha writes: --047d7b6d95d0367a3d04f01de490 Content-Type: text/plain; charset=ISO-8859-1 Hi everyone, I want to do operation with chars in the given string. Actually I want to grouping the same chars. For example; input : "34433

Re: Python solve problem with string operation

2014-01-16 Thread Tim Chase
On 2014-01-17 00:24, Nac Temha wrote: > Hi everyone, > > I want to do operation with chars in the given string. Actually I > want to grouping the same chars. > > For example; > > input : "3443331123377" > operation-> (3)(44)()(333)(11)(2)(33)(77) > output: "34131237" > > How can

Re: Python solve problem with string operation

2014-01-16 Thread John Gordon
In Nac Temha writes: > --047d7b6d95d0367a3d04f01de490 > Content-Type: text/plain; charset=ISO-8859-1 > Hi everyone, > I want to do operation with chars in the given string. Actually I want to > grouping the same chars. > For example; > input : "3443331123377" > operation-> (3)(44)(1

Python solve problem with string operation

2014-01-16 Thread Nac Temha
Hi everyone, I want to do operation with chars in the given string. Actually I want to grouping the same chars. For example; input : "3443331123377" operation-> (3)(44)()(333)(11)(2)(33)(77) output: "34131237" How can I do without list, regular expression. just using string op

Re: Problem with string format

2009-03-11 Thread Terry Reedy
Mike314 wrote: Hello, I have a strange problem with the string format: '%s %s %s %s %s' % ['01', '02', '03', '04', '05'] Traceback (most recent call last): File "", line 1, in TypeError: not enough arguments for format string But as soon I use tuple it is working: '%s %s %s %s %s' % (

Re: Problem with string format

2009-03-10 Thread John Machin
On Mar 11, 4:07 pm, Mike314 wrote: > Hello, > >    I have a strange problem with the string format: > > >>> '%s %s %s %s %s' % ['01', '02', '03', '04', '05'] > > Traceback (most recent call last): >   File "", line 1, in > TypeError: not enough arguments for format string > > But as soon I use tu

Re: Problem with string format

2009-03-10 Thread Mensanator
On Mar 11, 12:07 am, Mike314 wrote: > Hello, > >    I have a strange problem with the string format: > > >>> '%s %s %s %s %s' % ['01', '02', '03', '04', '05'] > > Traceback (most recent call last): >   File "", line 1, in > TypeError: not enough arguments for format string > > But as soon I use t

Re: Problem with string format

2009-03-10 Thread Steven D'Aprano
On Tue, 10 Mar 2009 22:07:59 -0700, Mike314 wrote: > Hello, > >I have a strange problem with the string format: > '%s %s %s %s %s' % ['01', '02', '03', '04', '05'] > Traceback (most recent call last): > File "", line 1, in > TypeError: not enough arguments for format string > > But

Problem with string format

2009-03-10 Thread Mike314
Hello, I have a strange problem with the string format: >>> '%s %s %s %s %s' % ['01', '02', '03', '04', '05'] Traceback (most recent call last): File "", line 1, in TypeError: not enough arguments for format string But as soon I use tuple it is working: >>> '%s %s %s %s %s' % ('01', '02',

Re: Problem with string -> int conversion ?

2005-08-31 Thread Fredrik Lundh
Madhusudan Singh wrote: >> if the callback code is Python, you should be able to add a print >> statement to the line just before the failing "int" call: >> >> print repr(signalrangestr), type(signalrangestr) >> signalrange = int(signalrangestr) >> >> that print statement should be all you

Re: Problem with string -> int conversion ?

2005-08-31 Thread Madhusudan Singh
Fredrik Lundh wrote: >> The code is : >> >> void Form3::getNPrange() >> { > > what language is this? Its python embedded in the designer workflow. pyuic extracts stuff from it, and generates a python script from the ui.h file. > > if the callback code is Python, you should be able to add a pr

Re: Problem with string -> int conversion ?

2005-08-30 Thread Fredrik Lundh
Madhusudan Singh wrote: > I am working with an application that I designed with the Designer > pyuic > workflow and I get the following error on trying to process the contents > of > a combobox : > > Traceback (most recent call last): > File "measure.py", line 908, in acquiredata >np=self.ge

Problem with string -> int conversion ?

2005-08-30 Thread Madhusudan Singh
Hi I am working with an application that I designed with the Designer > pyuic workflow and I get the following error on trying to process the contents of a combobox : Traceback (most recent call last): File "measure.py", line 908, in acquiredata np=self.getNPrange() File "measure.py", li

Re: problem with string

2005-07-22 Thread Michael Hoffman
Tzanko Tzanev wrote: > #but there is an error in > playlist_txt += mp3id + mp3_title + mp3_artist It'd be a lot easier to help if you'd say what the error was. -- Michael Hoffman -- http://mail.python.org/mailman/listinfo/python-list

Re: problem with string

2005-07-22 Thread Bruno Desthuilliers
Tzanko Tzanev a écrit : > hi :) > I need some help for this script > I have please take care of indentation when posting code. > > cursor = conn.cursor() > cursor.execute("select * from playlist limit 5") > result = cursor.fetchall() > # iterate through resultset > playlist_t

Re: problem with string

2005-07-22 Thread John Machin
Tzanko Tzanev wrote: > hi :) > I need some help for this script > I have > > cursor = conn.cursor() > cursor.execute("select * from playlist limit 5") > result = cursor.fetchall() > # iterate through resultset > playlist_txt = '' > for record in result: > mp3id = record[0] > mp

problem with string

2005-07-22 Thread Tzanko Tzanev
hi :) I need some help for this script I have cursor = conn.cursor() cursor.execute("select * from playlist limit 5") result = cursor.fetchall() # iterate through resultset playlist_txt = '' for record in result: mp3id = record[0] mp3_title = record[1] mp3_artist = record[2] pl