Skip to content

Instantly share code, notes, and snippets.

@ZechCodes
Created January 2, 2021 02:00
Show Gist options
  • Save ZechCodes/70052298c713db4298f78aaa582a131b to your computer and use it in GitHub Desktop.
Save ZechCodes/70052298c713db4298f78aaa582a131b to your computer and use it in GitHub Desktop.
Challenge 157 - Date Format

Challenge 157 - Date Format

Create a function that converts a date formatted as MM/DD/YYYY to YYYYDDMM.

Examples

format_date("11/12/2019") ➞ "20191211"

format_date("12/31/2019") ➞ "20193112"

format_date("01/15/2019") ➞ "20191501"

Notes

  • Return value should be a string.
import unittest
def format_date(date: str) -> str:
return "" # Put your code here!!!
class Test(unittest.TestCase):
def test_1(self):
self.assertEqual(format_date("11/12/2019"), "20191211")
def test_2(self):
self.assertEqual(format_date("12/31/2019"), "20193112")
def test_3(self):
self.assertEqual(format_date("01/15/2019"), "20191501")
if __name__ == "__main__":
unittest.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment