jeudi 9 août 2018

My if statement not working in python [duplicate]

This question already has an answer here:

I am trying to make a random sentence generator, and this piece of code should make the program use "an" when noun2 begins with a vowel.

import random
noun=['it', 'he', 'she', 'I']
verb=['am', 'is', 'are' ]
noun1=random.choice(noun).capitalize()+" "
verb1=random.choice(verb)+" "
noun2=random.choice(noun)+"."
if noun2[:1]=='a' or 'e' or 'i' or 'o' or 'u':
    asentence=noun1+verb1+'an '+noun2
    print(asentence)
else:
  print('hi')

But when I run the program, it always uses "an" even when noun2 starts with a consonant.

Aucun commentaire:

Enregistrer un commentaire