Advanced Search Function 2/2
Opgave
Swipe to start coding
- Import
re
. - Define a text variable as
"The cost is $5."
. - Search for any numerical value in the string.
- Print the output.
Løsning
import re
# Search for a digit in the text "The cost is $5."
text = "The cost is $5."
x = re.search("\d", text)
print(x) # Output: <re.Match object; span=(13, 14), match='5'>
Mark tasks as Completed
Var alt klart?
Tak for dine kommentarer!
Sektion 1. Kapitel 4
AVAILABLE TO ULTIMATE ONLY