icon picker
Code Optimiser

Optimize the code for multiple language instantly
info
Paste the code and select the source language
Click on the button “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 (
CtrlP
) instead.