samedi 16 février 2019

Given a string pattern with a variable, how to match and find variable string using python?

pattern = "world! {} "
text = "hello world! this is python"

Given the pattern and text above, how do I produce a function that would take pattern as the first argument and text as the second argument and output the word 'this'?

eg.

find_variable(pattern, text) ==> returns 'this' because 'this'

Aucun commentaire:

Enregistrer un commentaire