0
About Python MCQ
import re str = 'sololearn123' print(re.sub(r'[aA-zZ]',",str)) How the output is 123?
8 Answers
+ 11
Mustakim Rahman
the code as it is given is not completely correct:
print(re.sub(r'[aA-zZ]',",str))
^
the marked character is 1 double quote >"<, but should be 2 single quotes >''< since it represents an empty string.
the character group [aA-zZ] is working, but could be written also like: [a-zA-Z].
+ 9
Sandeep ,
i copied the code and pasted it in my local editor, where i could see a difference between 2 single quotes and 1 double quote.
+ 8
Sandeep ,
i am using pydroid on my android device. the font i am using is listed as *Monospace*
+ 5
thanks Lothar đ
I guess font choice really matters in programming
+ 4
Lothar how did you find it's a double quote? It looks exactly similar to two single quotes!
+ 4
Lothar which code editor do you use?
+ 3
re.sub() function replaces one or many matches with a string in the given text. The search and replacement happens from left to right.