Python Forum

Full Version: Hey guys, help a newbie out with a list problem.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey all,

As the title suggests, I'm quite new to python and programming in general,(although I have some basic understanding and have played a bit with programming before), I have a problem I am trying to solve, hopefully someone can help me out.

I have a list, the list if composed of numbers ranging from 1 to 10 in length. The first 6 digits are prefixes and repeat roughly 350 times the number after the prefix is random. The list is not ordered by the prefix, it is random. I am trying to renumber the list so that any numbers with the same prefix are sequenced, without reordering the list.

To visualize it it works something like this.

current list:
AAAAA.1
CCCCC.50
AAAAA.498
CCCCC.12
BBBBB.9
BBBBB.1954


Desired list:
AAAAA.1
CCCCC.1
AAAAA.2
CCCCC.2
BBBBB.1
BBBBB.2

Any help would be greatly appreciated.

Thanks,
S
Please show what you have tried so far, or at least how you envision that this could be done.
We are gladto help you solve the problem, but won't do it for you.
(Feb-15-2018, 05:06 PM)Larz60+ Wrote: [ -> ]Please show what you have tried so far, or at least how you envision that this could be done. We are gladto help you solve the problem, but won't do it for you.

Arghh I wrote a reply then hit the back button and lost it!!!!

Thanks Larz for the reply, I'll try it again in the morning, or if I have the energy, when I get home.