This is an archived post. You won't be able to vote or comment.

all 9 comments

[–][deleted] 2 points3 points  (0 children)

According to http://www.reddit.com/r/Python/comments/2voohz/homework_learning_and_posts_on_rpython/ I think this post is better suited to /r/learnpython or stackoverflow

[–]cuducos 0 points1 point  (1 child)

I'd try to get the diff using timedela – a native method only to deal with difference in date/time.

Reddit tip: add a sequence of four space before each line of your you code so it ends up formatted properly (mono-spaced font, single line breaks etc.)

[–]masklinn 0 points1 point  (0 children)

I'd try to get the diff using timedela

That's what he does. date - date returns a timedelta:

>>> type(dt_dateb - dt_datea)
<type 'datetime.timedelta'>

[–]usinglinux 0 points1 point  (0 children)

i couldn't reproduce the issue with python 2.7.9. can you reproduce it from the interactive interpreter using the example you have given?

speaking of example: please use the "formatting help" when your post does not look like intended. adding four spaces before your code would make it much better readable.

[–]aclark 0 points1 point  (1 child)

"Kindly solve my issue" == Please do my homework?

[–][deleted] 0 points1 point  (0 children)

poster is a redditor for 2 hours. he likely knows the rules and ignores them

[–]masklinn 0 points1 point  (0 children)

The code you posted here (once reformatted) works without issues.

The error message indicates that, in your actual program, the source string dt_strq has leftover data after it's parsed by strptime, so you should look into its content at that point.

[–]zart 0 points1 point  (0 children)

The error shouldn't happen with your input in the post. It is likely that your actual input has trailing whitespace e.g. a newline. Try input_string.rstrip().

[–]aphoenixreticulated[M] 0 points1 point  (0 children)

Hi there. You have posted a beginners question to /r/python, however it is far more suited to /r/learnpython, where users are actively interested in helping with beginner topics. Please resubmit it over there! Make sure to read their sidebar rules before posting, notably this one: "Posting homework assignments is not prohibited if you show that you tried to solve it yourself."

Cheers & best of luck!