Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAizah Sadiq
2,435 PointsIs it bad that I couldn't figure this out on my own
I tried doing it myself as the homework before checking this video and I couldn't figure it out. Do you think that I am behind?
4 Answers
Mark Sebeck
Treehouse Moderator 37,836 PointsNo Aizah it is not bad. If you knew how to do everything you wouldn't need to be taking these courses. Try your best then watch the solution and code along with the solution. If at the end of the course you don't feel you understand it take the course again. You will find that you understand a lot more the next time. Good luck and happy coding.
Joel Sprunger
5,448 PointsNo that's fine. Half the time I try to figure it out before watching the video I screw something up. But I think the exercise of trying first really does help you learn, because it shows you where you were thinking incorrectly. When you just start by watching a solution it is easy to follow along and feel like that is the natural logical solution. If you then watch the video and that doesn't make sense, you should probably dig further back into prior videos, or check other resources to clarify.
Aizah Sadiq
2,435 PointsSorry for the inconvenience! It is a video titled Wikipedia links
This is the code used in the video
import datetime
answer_format = '%m/%d'
link_format = '%b_%d'
link = 'https://en.wikipedia.org/wiki/{}'
while True:
answer = input("What date would you like? Please use the MM/DD format. Enter 'quit' to quit. ")
if answer.upper() == 'QUIT':
break
try:
date = datetime.datetime.strptime(answer, answer_format)
output = link.format(date.strftime(link_format))
print(output)
except ValueError:
print("That's not a valid date. Please try again.")
justlevy
6,325 PointsAizah Sadiq - I think it's OK to not know every solution to a challenge.
For the Wiki Links challenge, I approached it by writing out comments for the steps (using common English, not code). Then I worked on coding each step. It helped me break down the challenge to bite-sized bits.
Also, I did a lot of printing so I could see what was happening.
While not as elegant as Ken's solution, here's my code:
import datetime
def wiki_link():
user_date = input("Enter date eg. 05 12 (month day): ")
format_date = datetime.datetime.strptime(user_date, '%m %d')
url = format_date.strftime("%b") + "_" + format_date.strftime("%#d")
print("https://en.wikipedia.org/wiki/" + url)
wiki_link()
Joel Sprunger
5,448 PointsJoel Sprunger
5,448 PointsI do not have access to the problem. All I can see is the title and your question. This is a frustrating Treehouse "bug". You ask a question and it is easy to assume that everyone has access to what you are looking at. This gives me a path Python > Dates and Times in Python > Dates and Times > Wikipedia Links, but if I click on the path it doesn't take me to the content you are looking at. Please be more specific.