Menu
Coddy logo textTech

Number of Facts

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

The function is working, it is generating a random fact each time!

Now, let's call it X times.

challenge icon

Challenge

Easy

From outside the function, get input (a number) and call the function this number of times, each time, print the generated fact!

Make sure you are generating X number of 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']

All lessons in Random Fact Generator - Python Project