fork download
  1. from random import choice
  2.  
  3. vowels = ['а', 'и', 'о', 'у']
  4. consonants = ['н', 'з', 'г', 'ш', 'р', 'т', 'б', 'к', 'х']
  5.  
  6. rules = ['cVc', 'Cvc', 'cVC', 'CVc', 'cvC', 'CvC']
  7. currentString = 'гор'
  8.  
  9. res = ''
  10. rule = choice(rules)
  11.  
  12. for cur, r in zip(currentString, rule):
  13. if r.islower():
  14. res += cur
  15. elif r == 'C':
  16. res += choice(consonants)
  17. else:
  18. res += choice(vowels)
  19.  
  20. print(rule, currentString, res, sep='\n')
Success #stdin #stdout 0.02s 11660KB
stdin
Standard input is empty
stdout
cvC
гор
гоб