There is a string like sdd,L12,W45,H78,7cm,K,D6

It is necessary to break into 12,45,78,7 by separate variables for insertion into the database.

The task is eletnarnoe .. It is very urgent to implement in Python, never worked in Python, thanks

  • What are you having difficulties with? The solution of full-fledged tasks does not coincide with the policy of this site. - Geslot
  • 12,45,78,7 But what about 6 ? - gil9red

2 answers 2

I'm not sure I understood the question correctly, but the split function breaks the string into a sequence of values:

  t=s.split(',') 

And then I would use for and if to check if the text contains a number, and if so, write it to an array.

  • Julia, you are generally right. ) Probably minus the educational set you, because unformatted question) - Nick Volynkin
  • I just registered on the site today, still not quite aware of local rules. Probably, I will not write anything for the time being, until I’ve written anything at all)) - Julia
  • do not worry) the main thing is to stay and take part - Nick Volynkin

The solution is really elementary:

  • using regulars delete all characters except 0-9 and ',' (comma)
  • split to split a line into a list
  • remove empty items from the list