+ 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
9 Antworten
+ 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))
+ 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
+ 1
Will you please share your code...?
+ 1
def vowel_counter(string):
counter = 0
for char in string:
if char in ('aeiou'):
counter +=1
return counter
+ 1
Dennis Abele I don't see where you are trying to take input
+ 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)
+ 1
Paul K Sadler Sir, Thank you for the kind words. Actually, I messed with both variables strng and string.
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?
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.