a few months ago, John W. Kennedy contributed this nifty item:
> **************Ruby***************
> # this program generates all possible syllables
> initials = %w/b ch d/
> medials = %w/a i u/
> finals = [''] + %w/n s/
> open('syllables.txt', 'w') do |out|
> initials.each do |initial|
> medials.each do |medial|
> finals.each do |final|
> out.puts initial + medial + final
> end
> end
> end
> end
> puts 'Finished. It was a pleasure to serve you.'
I am trying to learn Python (but I just started a few hours ago). I'm
trying to translate this into Python.
initials = ['b', 'c', 'd']
medials = ['a', 'i', 'u']
finals = [' ', 'n', 's']
out_file = open("syllables.txt","w")
I'm not sure how to do the rest. Suggestions? I would like to be able
to add or subtract items in the lists of initials, medials and finals
without making any changes to the rest of the program.


|