Menu
Coddy logo textTech

Final words

Lesson 7 of 7 in Coddy's Random Fact Generator - Python Project course.

That's it! You have a working fact generator!

What's next? here are some ideas:

challenge icon

Challenge

Easy

Run the code to complete the project, and generate 3 facts :)

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())
if n > 7:
    print('Maximum number of facts per execution is 7')
elif n <= 0:
    print('Minimum number of facts per execution is 1')
else:
    for i in range(n):
        print(get_fact())

All lessons in Random Fact Generator - Python Project