0
re.sub(r'a(?=b)','*','The lion and the Fox')
I need to get the inputs and then substitute with * but Im not getting output , like if I give, a=input() b=input() c=input () print(re.sub(r'a(?=b)','*',c)) Instead of the input string, the characters a and b are replaced in 'c'. How to replace the given string with the INPUTS a and b ??
7 odpowiedzi
0
Valmob101 a=aa b=bb c= my string is aa bb , output:: my string is * bb
+ 1
use:( f ".........." ) instead of r , then place variables inside {}.
e.g. f "hello{a}"
+ 1
Mndm r stands for raw string which means the string cannot escape character by \(backslash)
f stands for format in which we can include identifiers, vars etc. Inside{}. It is a replacement for .format.
0
Valmob101 sorry but I didn't get the output
0
Mndm Please also include the output you want.
0
Mndm solution to yours:
Use this pattern instead:
re.sub(f'{a} (?={b})','* ',c)
To fulfil your output you should include *space* after {a} and *
0
Lerninn
K = 2
List = '1001101100011'
result = re.findall(f'1{k}',List)
I'm not getting output ? Can you help