i need to be able to have python spit out a date like this (mm/dd/yyyy) even if the user doesnt add the "/" to there input. here is what i got so far.

import string
date = raw_input(enter your date:")
print date[0:2]+'/',date[2:4]+'/',date[4:8]

the output is mm/ dd/ yyyy.

how would you go about getting rid of the blank spaces in front of dd and yyyy?

Recommended Answers

All 2 Replies

Replace the commas by plus.
What do you expect the user to enter? You may want to give some kind of a templet/hint in your prompt.

I would assign your date variable into a date type variable (I think it was something like datetime just look it up). so you will have a real date. then you can easiliy format your out put.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.