Giter VIP home page Giter VIP logo

randomjokeapi's Introduction

randomjokeapi's People

Contributors

leahcimto avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

steve0greatness

randomjokeapi's Issues

Use random.choice

return {"joke":jokes[random.randrange(0, len(jokes))]}

Here, random.choice does the same job:

return  { "joke": random.choice(jokes) }

There is no competition here.
random.choice(jokes) > jokes[random.randrange(0, len(jokes))]

Switch to using a TXT file instead of a JSON file

Currently, you're using a JSON file to store the API, but I think that you should use TXT instead.

It's really easy to switch even, just use

jokes = file.read().split("\n")

in main.py on line 8(also, make sure line 7 uses jokes.txt instead of jokes.json).

Here are some reasons for switching over:

  1. Plain text files are easier to add to, all you need to do is add a new line and type
  2. Smaller file size, but just by a few bytes(it scales more the larger the file gets).

I've also already made it into a txt doc:

What's the best thing about Switzerland? I don't know, but the flag is a big plus.
Someone tells his doctor, "Doc, help me. I'm addicted to Twitter!" The doctor replies, "Sorry, I don't follow you…"
What did the 0 say to the 8? Nice belt!
I used to think the brain was the most important organ. Then I thought, look what's telling me that.
Do you want to hear a construction joke? Sorry, I'm still working on it.
What gets wetter the more it dries? A towel.
How does NASA organize a party? They planet.
Why does Humpty Dumpty love autumn?  Because Humpty Dumpty had a great fall.
Why was the math book sad? Because it had so many problems.
If you see a robbery at an Apple Store does that make you… an iWitness?!
Why did Karen press CTRL + Alt + Delete? She wanted the Task Manager.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.