mercredi 20 février 2019

Print a 4 letter word

My code below prints random 4 letters and working great. However, I want to upgrade it to print any 4 letter word. I mean a meaningful word and not just non meaningful 4 letters

CODES

      import random

      import string

      count = 0
      word = ''
      while count < 4:
        letter = random.choice(string.ascii_lowercase)
        count = count + 1
        word = word + letter
      print(word)

OUTPUTS

CURRENT OUTPUT: fxgw (non meaningful output)

EXPECTED OUTPUT: work (meaningful output)




Aucun commentaire:

Enregistrer un commentaire