JavaScript required
We’re sorry, but Coda doesn’t work properly without JavaScript enabled.
Skip to content
Gallery
AI Code Assist
About this template
Universal Coding Helper
Code Optimiser
Skills Upgrader
Code Templates
Comparison of Languages
5Best
More
Share
Explore
Code Optimiser
Optimize the code for multiple language instantly
Paste the code and select the source language
Click on the button “Optimize”
Enter Code to Optimize
Enter Code to Optimize
1
current_date = none
from datetime import datetime
print("Current date is: " + current_date.strftime('%Y-%m-%d'))
dateinput = input("Enter date in yyyy-mm-dd format: ")
current_date = datetime.now()
try:
date_provided = datetime.strptime(dateinput, '%Y-%m-%d')
except ValueError as e:
print(e)
rollbar.report_exc_info()
exit()
There are no rows in this table
Python
Optimise
python
# Optimized code
from datetime import datetime
current_date = datetime.now()
print("Current date is: " + current_date.strftime('%Y-%m-%d'))
dateinput = input("Enter date in yyyy-mm-dd format: ")
try:
date_provided = datetime.strptime(dateinput, '%Y-%m-%d')
except ValueError as e:
print(e)
rollbar.report_exc_info()
exit()
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
Ctrl
P
) instead.