Limitations
Lesson 6 of 7 in Coddy's Random Fact Generator - Python Project course.
Let's add some limitations
Challenge
EasyIf the input number is greater than 7, output "Maximum number of facts per execution is 7".
If the input number is smaller than 0, output "Minimum number of facts per execution is 1".
For this project, we will assume the input will always be a number.
Try it yourself
import requests
import json
def get_fact():
response = requests.get('https://uselessfacts.jsph.pl/api/v2/facts/random')
content = response.text
data = json.loads(content)
return data['text']
n = int(input())
for i in range(n):
print(get_fact())