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
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
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
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
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
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
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
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
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