Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Education > Language Artificial > Python programm...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 4 Topic 920 of 953
Post > Topic >>

Python programming question

by Rick Harrison <not@[EMAIL PROTECTED] > Jun 22, 2008 at 11:17 PM

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.
 




 4 Posts in Topic:
Python programming question
Rick Harrison <not@[EM  2008-06-22 23:17:53 
Re: Python programming question
Rick Harrison <not@[EM  2008-06-23 16:46:33 
Re: Python programming question
Carl Banks <pavlovevid  2008-06-23 18:38:47 
Re: Python programming question
Rick Harrison <_nickna  2008-06-25 03:53:04 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 3:25:36 CST 2008.