d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Iso Help
Add Reply New Topic New Poll
Member
Posts: 22,291
Joined: May 15 2009
Gold: 900.00
Aug 24 2019 12:46pm
I'd like to be able to take a list of items (no longer than 100) and add a searchable character count to the end. Preferably would be able to arrange them in a shortest -> longest format (or vice versa)

For example a list like:

The Beatles

Aerosmith

Led Zeppelin

The Rolling Stones


Would translate to:

Aerosmith (9)

The Beatles (3, 7)

The Rolling Stones (3, 7, 6)

Led Zeppelin (3, 8)

I'm not sure the best way to accomplish this but would be willing to pay fgs if someone can help. Thanks!

This post was edited by haDs on Aug 24 2019 12:47pm
Member
Posts: 3,028
Joined: Mar 23 2016
Gold: 7,568.50
Aug 24 2019 03:51pm
I gave it a shot, not sure what exactly you meant by 'searchable character count' though.


https://jsfiddle.net/yan4mf89/
Member
Posts: 36,123
Joined: Jul 18 2008
Gold: 2,407.00
Sep 13 2019 09:13pm
Not sure if this is still needed but I'll post some pseudocode below to help you out:

Code
for line in text_list

splits = line.split(" ")

for word in splits:
line.append(" " + word.length)
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll