0

I am trying to concert a list which has words and and points score next to it into a dictionary the list looks roughly like this ("oliver34", "jack17" , "jane56") I want to split this into ("oliver", "34" "jack" , "17" , "jane", "56" so that I can turn them into a dictionary. if this can be done without importing anything that would be preferable

sorry if this does make sense first time using stack overflow and im not good at coding

  • What about names [that contain numbers](https://www.kalzumeus.com/2010/06/17/falsehoods-programmers-believe-about-names/)? What have you tried? – Sayse Jan 14 '21 at 12:32
  • I've tried input.split([i]) which did nothing and just failed – Ole Sutton Jan 14 '21 at 14:07

1 Answers1

0

If the variables inside the list always have the same format which is a name followed by a number, then you can just do this:

def text_num_split(item):
for index, letter in enumerate(item, 0):
    if letter.isdigit():
        return [item[:index],item[index:]]
dorukr0t
  • 55
  • 1
  • 8
  • sorry I missed your response, are index item and letter all variables simple question i'm just trying to figure out how your code works as I said very new to coding – Ole Sutton Jan 14 '21 at 13:18
  • item would be your list of names and index is just helping us to go through your list and splitting the names and numbers – dorukr0t Jan 14 '21 at 14:26