Count vowels from raw input

后端 未结 6 1878
轮回少年
轮回少年 2021-01-14 09:09

I have a homework question which asks to read a string through raw input and count how many vowels are in the string. This is what I have so far but I have encountered a pro

6条回答
  •  庸人自扰
    2021-01-14 09:39

    Option on a theme

    Mystring = "The lazy DOG jumped Over"
    Usestring = ""
    count=0
    for i in Mystring:
        if i.lower() in 'aeiou':
            count +=1
            Usestring +='^'
        else:
            Usestring +=' '
    
    print (Mystring+'\n'+Usestring)
    print ('Vowels =',count)
    
    The lazy DOG jumped Over
      ^  ^    ^   ^  ^  ^ ^ 
    Vowels = 7
    

提交回复
热议问题