Issue
How would I go about designing a Python program which takes in a date from the user, a date that looks like this 3/13/17, and turns it into a date which looks like this 2017.3.13?
Solution
You can split the string by using the str.split
method like this:
s = "3/13/17"
month, day, year = s.split("/")
print(f"20{year}.{month}.{day}")
Python will automatically assign the splitted values to the variables month, day, and year
Answered By - The Peeps191
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.