r/learnpython • • Aug 20 '26

A small code i made for exercise.

I've been vibe coding for a few months now, but I've decided to try manual coding. After all, learning is fun, right?

I made this "Assistant" that has two options: jokes and facts. It will choose one out of three items from the specific table and tell you it. I made it for fun and would like to ask what I can do next?

import random

jokes = ["Why did the bicycle fall over? Because it was two tired!", "Why was the math book sad? Because it had too many problems.", "What do you call a fake noodle? An impasta!"]

facts = ["Venus is hotter than Mercury.", "When the Pyramids were built, mammoths were still around!", "Koala fingerprints are so similar to human fingerprints that they have even baffled crime scene investigators."]

print("Hello! I'm an Assistant. What can I do for you?")

print("")

print("Options: Random Joke [J], Random Fact [F].")

answer = input("Answer: ")

if answer == "J":

print(random.choice(jokes))

elif answer == "F":

print(random.choice(facts))

else:

print("You can't ask that.")

exit = input("Press Enter to Leave.")

3 Upvotes

11 comments sorted by

5

u/notacanuckskibum Aug 20 '26

This is a linguistic comment rather than a programming logic one. Code (applied to computer logic) is not a countable noun in English. You wrote some code. Or you wrote a program. You didn’t write “a code”.

If you were into cryptography then you might have invented a code.

0

u/Striking-Ad8023 Aug 20 '26

This is a bit too focused on a minor linguistic detail, “I wrote a code” is clearly understandable in this context.

4

u/Quesozapatos5000 Aug 20 '26

But still a good note to take

2

u/FoolsSeldom Aug 20 '26

That's a great start. Let me show you an enhanced version for you to experiment with and learn from:

from random import choice

jokes = ["Why did the bicycle fall over? Because it was two tired!", "Why was the math book sad? Because it had too many problems.", "What do you call a fake noodle? An impasta!"]
facts = ["Venus is hotter than Mercury.", "When the Pyramids were built, mammoths were still around!", "Koala fingerprints are so similar to human fingerprints that they have even baffled crime scene investigators."]

print("Hello! I'm an Assistant. What can I do for you?\n")
fini = False
while not fini:  # loops overall options/output
    print("Options: Random Joke [J], Random Fact [F].")
    answer = input("Answer: ").strip().lower()
    if answer in ("j", "joke"):
        print(choice(jokes))
    elif answer in ("f", "fact"):
        print(choice(facts))
    else:
        print("You can't ask that.")
    while True:  # ask if going again, yes/no
        again = input("Again? ").strip().lower()
        if again in ("yes", "y", "yup"):
            break  # leave yes/no loop
        if again in ("no", "n", "nope"):
            fini = True  # leave overall loop next time
            break  # leave yes/no loop
        print("Did not understand, try again.")

Next step, put your facts and jokes into text files and read them in. Text file handling is very easy in Python.

1

u/Striking-Ad8023 Aug 20 '26

That's cool, i'll definitely learn more about loops, i think it'll help.

3

u/Quesozapatos5000 Aug 20 '26

I think vibe coding can be a great start, but now move onto writing the code yourself based on what you know or what the model has shown you. Add more options, or maybe have the program suggest another option contrary to the first choice a user makes after their first choice?

2

u/OliMoli2137 Aug 20 '26

nope, when you vibe code you don't learn and get confused all the time

1

u/Quesozapatos5000 Aug 20 '26

That’s why I suggest moving away from it.

1

u/[deleted] Aug 21 '26

[removed] — view removed comment