Skip to content
Sign upLog in
← Back to Community
Function to print the current date
Profile icon
stalinbabu

While calling the function how do we use this type of call

m, d, y = c_date()

Voters
Profile icon
stalinbabu
Comments
hotnewtop
Profile icon
Nettakrim

why are you importing datetime inside the loop

also use

''' multi line comment! yay this is cool! ''' ####################### dont do this! #################
Profile icon
CalebCarlson

The issue with your code is you defined the variables m,dand y inside of the def statement of a function.
Whenever you define a function, to put it simply, any variables you define inside of that function, stay inside of the function. so if you want to use those same variables outside of your function, you will have to define them outside of your function


In python we call this global and local scope.

Profile icon
helloyanis

There is a function to print the date!
Here it is :

import time
print(time.asctime())