Skip to content

Instantly share code, notes, and snippets.

@CrumblyLiquid
Created May 23, 2022 16:19
Show Gist options
  • Save CrumblyLiquid/93cb9686400baae6fe8b1117f34f036a to your computer and use it in GitHub Desktop.
Save CrumblyLiquid/93cb9686400baae6fe8b1117f34f036a to your computer and use it in GitHub Desktop.
Quick and dirty script to practice words
from pathlib import Path
import random
# File should be in format:
# word - translation
file = Path(input("Please enter file: "))
wordlist = []
# Load file and create wordlist
with open(file, "r") as f:
text = file.read_text();
array = text.split("\n")
for item in array:
if(item != ""):
split = item.split(" - ")
wordlist.append((split[0].lstrip("\t").lstrip(" "), split[1]))
# Shuffle words
random.shuffle(wordlist)
# Select order
firstwordfirst = False
for item in wordlist:
# german word first
if firstwordfirst:
one = item[0]
two = item[1]
# czech word first
else:
one = item[1]
two = item[0]
# Only prints word and then the answer
print(f"Word: {one}", end="")
input()
print(f" -> {two}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment