Answer the question
In order to leave comments, you need to log in
Why does the function return None?
from datetime import date, timedelta
import os
os.system('cls')
def date():
s = input("Write 1 for today, 2 for yesterday and 3 for random date: ")
if s == 1:
last_date = (date.today())
link_today = "https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY&date=" + str(last_date)
return link_today
elif s == 2:
yesterday = print(date.today() + timedelta(days=-1)
return yesterday
date()
Answer the question
In order to leave comments, you need to log in
First, input returns a string, which obviously cannot equal a number. Secondly, there are no alternative conditions.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question