[Python] Vocabulary review program

Discussão em 'Python' iniciado por Stack, Janeiro 27, 2025.

  1. Stack

    Stack Membro Participativo

    I'm making a program that helps me revise vocabulary. Through a lot of trail and error I got the point where it almost works but there's a tiny issue where in the "second phase" the bugs start to happen.

    The program basically has a list of the words that I learnt. It should ask for how many words would you like to revise (let's call it n) and then choose n number of random words from the list of words. After that's done it should remove the words that it selected from the original list and ask if you want to revise more, asking you again to give them the number of words you would like and it's just rinse and repeat until the list is finally empty. Here's my code so far.

    import random

    def word_get(pool, number):
    if number > len(pool):
    print("Oop, we don't have that many words yet!")
    elif len(pool) == 0:
    print ("Congrats! You've reviewed all of your learnt words!")
    else:
    shuffle = random.sample(pool, number)
    selected = []
    for i in shuffle:
    selected.append(i)
    for i in pool:
    if i in selected:
    pool.remove(i)
    print (shuffle)
    got_kanji = True
    return

    def next_list():
    next = input("would you like another list? (yes or no) ")
    return next.lower().startswith("y")


    #Program Start

    print ("K A N J I S T U D Y")
    words = "Book_Store Food Wait Tokyo Kyoto Osaka Read What Temple Before Afternoon Study Know Picture Music Time Bank " \
    "Go Weekend Library Sunday Monday Tuesday Wednesday Thursday Friday Saturday Cinema Home_place Between Under " \
    "Over Inside Half See Return Teacher English Japanese Korean Chinese Eat Evening University Kanji Ahead " \
    "Student Talk Wake_up Me Dad Morning Come Capture Hear Sleep Hospital Town Place Fish Workbook House " \
    "Exchange_Student Vegetables Forget Cat Yesterday Meat Bring Year_after_next Counter_for_flat_things Hold " \
    "Aniaml Sea Busy Use Years_old Together Terrible Child Last_year Homework Luggage Friend Weather Quiet Later " \
    "Mother Father Swim Rest Borrow Teach Hot(Wheather) Cold(wheather) Return_something Classroom Like Tea Really " \
    "Name Room Birthday Sit Best Difficult Next To_get_off Death Delete/Turnoff Turn Marriage Hair Play/Hangout " \
    "Electricity Road Near Long Window Cease North Wear_from_shoulders_down Cafeteria To_Open Inhale/Smoke/Suck " \
    "East Reach Family Park Shoes Company Head South Older_sister Younger_sister to_gain_weight to_stand Joke " \
    "West Older_Brother Younger_brother To_take_along Who Traffic_light Move Enter Aid Reside Phone_Call Train " \
    "Back/Spine To_Close Bag Side Cheap Power_Outage Car Right Left Store Son To_breakup Corner Sing Flower Laugh " \
    "Short Research/Investigation Schdedule Bullet_Train Alcohol Manager Hokkaidou Exercise Popular Kyuushuu " \
    "Boat/Ship Cold(thing) Hot(thing) Next/This_Time Singer Resevation Mt.Fuji Kimono Body Husband To_keep(a_pet) " \
    "Seasons Autumn Summer Spring Vegetables Warm Chopsticks Older/Senior Short(people) Paper Beauty_Parlor " \
    "To_walk Quick Early Baseball Plane World Sleepy Doctor A_long_time Journey Introduce Beginning Famous " \
    "Refreshing Stop Sweets/Candy Nagano Climb Hiroshima Question Lake Driving Dream Future Unfortunately/Sadly " \
    "To_Work Learn Festival Outside To_get_tired your_wife your/her_husband my_wife my_dear/honey Grandfather " \
    "Grandmother Eye Eyebrow Nose Mouth Tooth Ear Hair Head Face Neck Shouler Chest Stomach Arm Hand Leg Finger " \
    "Crotch Think Skillful Unskillful Cooking To_Make Cut Start Late/Slow Cheers! Test Cleaning Self/Myself " \
    "Shower Walk Vocabulary Interesting/Funny Male Lunch_box Young Composition Winter Hurry To_play(instrument) " \
    "To_wash Laundry Remember To_Leave/Throw_away To_end Medicine Village Forest New Dark/Black Red Blue Yellow " \
    "White Light_brown Green Deep_Blue Light_Blue Silver Color Grey Purple/Violet Hurts Grades Smile " \
    "That_person/Boyfriend Expensive/Tall Girlfriend Rain Rains A_little_bit Obtain To_lose_something Ticket " \
    "To_go_out Clothes To_Notice To_run To_be_in_time Nervousness".split()



    got_kanji = False


    while len(words) > 0:
    print ("Number of available words:", len(words))
    n = int(input("How many words would you like?: "))
    word_get (words, n)
    got_kanji = True

    if got_kanji:
    if next_list():
    got_kanji = False
    else:
    break


    The issue is that the number of remaining words after taking the first list is inaccurate, especially when asking for a list that has 50+ words.

    Continue reading...

Compartilhe esta Página