On 15/09/17 04:08, Pratyusha Thundena wrote: > How do check to see if string ‘garden’ contains a > vowel(a, e , i , o, u , or y) using a for loop?
Hi, this sounds like homework and we won't do your homework for you, but we do give hints. How would you do this without a computer? There are (at least) two ways: 1) you can check each letter in your word and see if it is a vowel. 2) we can check each vowel and see if it is in your word A for loop gives you each item in a sequence one by one so would work in either solution. Let's consider option 1 in pseudo-code: for each letter in word: if letter is a vowel: do something... what? So that leads to two questions: 1) how do you tell if a letter is a vowel? Hint: look at what the string 'in' operator does 2) What do you want to do if you find a vowel? print something? exit? or what...? See if that helps, if you still need help come back with a specific question (the more specific the question, the more specific will be the answer) and show us your code plus any error messages you received. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor