+ 4
How can I solve python code couch longest word
16 Respostas
+ 7
Just a Hint:
You can use string method ".split()" to have a list which contain each word of the sentence each element.
You can also use the string method "len" to find how many letters are in a word.
And if you encounter an error in your code, just show your attempt here and we may help you fix it.
Good Luck!
+ 6
Omkaar , just give an addition hint to what ă Nicko12 ă mentioned:
- split input sentence to a list using split()
- use a for loop to iterate over that list of words, and check each word for the length. <<<----
- find the longest word
+ 6
yes. code couch
+ 3
Thank you guys
+ 3
I have done it
+ 2
You should take the input since it is a challenge, cause challenge has different test
cases which means different inputs
Here is how to take input values
x = int(input())
y = int(input())
print(x + y)
- - - - - - - - - - - - - -
We used "int" to declare input values as an integer because "input()" takes values as string as default. And we need it to be an integer so that we can add it so we need it to be " int(input()) ". Then assign the input value to a variable, here in the code above the variables are x and y. (x holds/stores first input value and y holds/stores the second value.)
Then lastly we print the output or the sum of our two variables. " print(x + y) "
+ 2
Yeah it is actually hidden and cannot be seen.
Imagine if a solver can see all input values, then he/she will just print the expected output, right?
So the purpose of it having hidden test cases is so that a solver will create a code/pattern/algorithm that satisfies whatever the input may there be. Dont worry input will be taken even though these test cases are hidden, just read the instruction of the problem of what the input may look like.
+ 2
Thank you brother you are best
+ 1
Alright, show your code attempt so far.
+ 1
But in code coach input box in which write don't come.
And how can I solve two test cases
+ 1
First, read and anlalyze the challenge's/problem's instruction carefully. It is written their what should be done, what should be the input, and what should be the output.
Then, another way.
Look at the first 2 cases and observe what kind of input is there, For Example for test case 1:
Input:
2
4
- - - - - - - - - - - - - -
Then you now have a clue here, that you need to take input of two integers which will look like this on your code.
x = int(input())
y = int(input())
#Then some code that will satisfy the expected output
- - - - - - - - - - - - - - - -
Remember that in challenges input block, every line means new input variable. For example It has 3 lines of input
Input:
1
2
3
- - - - - - - - - - - - - - -
Then you need Three(3) variables to hold this inputs.
x = int(input())
y = int(input())
z = int(input())
#Then some code that will satisfy the expected output
0
I am having problem in one more "Simple calculator"
I cannot get the answer can you please helps me.
0
# your code goes here
x=5
y=4
a=22
b=11
print(x+y)
print(a+b)
0
So how can I solve them
0
My one line code:
print(max(input().split(), key = len))
- 3
Hi