Printing strings


#1



https://www.codecademy.com/courses/python-beginner-en-zFPOx/0/4?curriculum_id=4f89dab3d788890003000096


Code works fine as expected.


I don't expect the code to print the string as it is in single quotes. But it prints even without double quotes.


from datetime import datetime
now = datetime.now()

print '%s/%s/%s' % (now.month, now.day, now.year,)


#2

Nothing wrong with using either '' or "" for this kind of situation. Both are meant as strings.
If you want to know more about the difference between '' or "" for strings, this link is a nice start.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.