Advanced Search Function 2/2
Compito
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.
Soluzione
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
Tutto è chiaro?
Grazie per i tuoi commenti!
Sezione 1. Capitolo 4
AVAILABLE TO ULTIMATE ONLY