#japanese.py #generate random pseudo-Japanese "words" import random #a list of 63 syllables: syllables = ["a","i","u","e","o", "ka","ki","ku","ke","ko", "ga","gi","gu","ge","go", "sa","shi","su","se","so", "za","ji","zu","ze","zo", "ta","chi","tsu","te","to", "na","ni","nu","ne","no", "ha","hi","fu","he","ho", "ba","bi","bu","be","bo", "pa","pi","pu","pe","po", "ma","mi","mu","me","mo", "ra","ri","ru","re","ro", "ya", "yu", "yo"] number_words = int(input("How many random pseudo-Japanese 'words'?: ")) number_syllables = int(input("Maximum number of syllables per word?: ")) all_same_length = True if input("All same length? (y or n): ")=='y' else False words = [] for i in range(number_words): if all_same_length: num_syls = number_syllables else: num_syls = random.randint(1,number_syllables) words.append("") #start with empty string #then some random syllables for syl in range(num_syls): words[i] = words[i] + syllables[random.randint(0,len(syllables)-1)] show_data = True if input("Show the random words? (y or n): ")=='y' else False if show_data: print("Before the sorting: ") for word in words: print(word, end=" ") print() words.sort() show_data = True if input("Show the sorted words? (y or n): ")=='y' else False if show_data: print("After the sorting: ") for word in words: print(word, end=" ") print()