Python Forum
Vowels and Consonants detector
Thread Rating:
  • 2 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Vowels and Consonants detector
#5
Isn't c the string that is supposed to be called later on in the code?

def is_vowel(c):
    for character in c:
        print(character, True)
    for character in c:
        print(character, False)
I adjusted it to this code, still giving me the same results.


I have realized that when it's finding a vowel, it is printing True 6 times, which is the length of the string 'banana'. Same thing goes for when it finds a consonant.
Unlike this code:

def is_vowel2(c):
    for character in c: #The Character in the word defined by the letter "c"
        if character in vowels: #If this character is in the list "vowels"
            print(True) #The statement is then a vowel, which is true!
        else: #If not, or if else
            print(False) #The statement is false, then it is a consonant!
Fortunately, I have to do it both ways (using if conditionals and without using them) so I can actually study both. Help?
Reply


Messages In This Thread
Vowels and Consonants detector - by OmarSinno - Sep-21-2017, 09:57 AM
RE: Vowels and Consonants detector - by buran - Sep-21-2017, 10:05 AM
RE: Vowels and Consonants detector - by Sagar - Sep-21-2017, 10:58 AM
RE: Vowels and Consonants detector - by j.crater - Sep-21-2017, 11:04 AM
RE: Vowels and Consonants detector - by OmarSinno - Sep-21-2017, 12:54 PM
RE: Vowels and Consonants detector - by buran - Sep-21-2017, 02:27 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Prime number detector Mark17 5 901 Nov-27-2023, 12:53 PM
Last Post: deanhystad
  remove vowels in word with conditional ambrozote 12 4,268 May-02-2021, 06:57 PM
Last Post: perfringo
  Face detector project? korenron 2 2,168 Mar-24-2021, 03:43 PM
Last Post: korenron
  counting vowels in a string project_science 3 2,634 Dec-30-2020, 06:44 PM
Last Post: buran
  qrcode detector not in cv2 Pedroski55 2 5,219 Sep-16-2020, 03:22 AM
Last Post: Pedroski55
  Counting vowels in a string (PyBite #106) Drone4four 4 2,327 Jul-07-2020, 05:29 AM
Last Post: theknowshares
  Smoke detector + send email Brandon99 4 4,030 Sep-12-2018, 11:18 PM
Last Post: Brandon99
  no vowels function alex_bgtv 6 5,130 Jan-01-2018, 08:48 PM
Last Post: alex_bgtv
  replace vowels niru 9 20,882 Sep-26-2017, 12:46 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020