If I input "1995y 05m 05d", then I want to make a program that prints "950505"
more example: "1949y 05m 23d" --> "490523"
import re Birthday = str(input("insert your birth<(ex) xxxxy **m 00d> : ")) p= re.sub('[ymd ]','',Birthday) print(p) #result is "xxxx**00"
here is my code. How do I fix it? any solutions?
Your existing code prints the full year, where you want only two digits. Just skip the first two digits on print.
That will print
p starting from position 2 (the third character, since lists are counted from 0), with no end to the range, so it prints the entire string except the first two characters (
19 in your sample).