Python Forum
Hey guys, help a newbie out with a list problem. - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Hey guys, help a newbie out with a list problem. (/thread-8344.html)



Hey guys, help a newbie out with a list problem. - sdezigner - Feb-15-2018

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


RE: Hey guys, help a newbie out with a list problem. - Larz60+ - Feb-15-2018

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.


RE: Hey guys, help a newbie out with a list problem. - sdezigner - Feb-15-2018

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