+ 1

inputs

I am doing one of the code coaches, but don't know how to setup the code so that it recognizes the inputs that application uses. In particular i am doing the vowel counting one. i have created my function, which takes one argument. i am running it and works in visual studio and Jupyter, but dont understand how the problem inputs the strings so that

10th Sep 2021, 4:31 PM
Dennis Abele
Dennis Abele - avatar
9 Respostas
+ 3
Hi Dennis! Here, your concept is fine. But problem is that you let some tiny mistakes. That's why you were unable to print the output. 1. You're missing an "i" in string variable. 2. You forgot to use print statement for vowel_counter() function to print the output. Here it is your corrected code. string = input() def vowel_counter(string): counter = 0 for char in string: if char in ('aeiou'): counter +=1 return counter print(vowel_counter(string))
11th Sep 2021, 2:25 AM
Python Learner
Python Learner - avatar
+ 3
JUMP_LINK__&&__Python__&&__JUMP_LINK Learner Dennis Abele I don't see Dennis missing an 'i', I ran his code and it worked fine. He did need a print statement as I pointed out a few hours ago. But glad to see you trying to help him! We can all learn together
11th Sep 2021, 2:33 AM
Paul K Sadler
Paul K Sadler - avatar
+ 1
Will you please share your code...?
10th Sep 2021, 4:52 PM
Rupali Haldiya
Rupali Haldiya - avatar
+ 1
def vowel_counter(string): counter = 0 for char in string: if char in ('aeiou'): counter +=1 return counter
10th Sep 2021, 4:57 PM
Dennis Abele
Dennis Abele - avatar
+ 1
Dennis Abele I don't see where you are trying to take input
10th Sep 2021, 5:08 PM
Paul K Sadler
Paul K Sadler - avatar
+ 1
Ive also tried the below. What I am trying to ask is how does the code want the input to be put in. : strng = input() def vowel_counter(string): counter = 0 for char in string: if char in ('aeiou'): counter +=1 return counter vowel_counter(strng)
10th Sep 2021, 6:44 PM
Dennis Abele
Dennis Abele - avatar
+ 1
Paul K Sadler Sir, Thank you for the kind words. Actually, I messed with both variables strng and string.
11th Sep 2021, 7:01 AM
Python Learner
Python Learner - avatar
0
So with the input 'this is my string' I changed the last line to: print(vowel_counter(string)) And it correctly outputs 3 Are you expecting something else?
10th Sep 2021, 7:14 PM
Paul K Sadler
Paul K Sadler - avatar
0
Sololearn expects all input at once in an alert box which has a submit button. This is presented as soon as you click run.. Imagine you have a loop that asks for five numbers to be input. In the alert box you would enter it like this: 1 2 3 4 5 And then click submit. All input is text so an integer would need the code int(input()) for an example.
10th Sep 2021, 8:32 PM
Paul K Sadler
Paul K Sadler - avatar