Python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Python

Hello, I would like to ask someone here a question because i got some homework from my IT teacher and i need to create a little programm where i write hi and hello and the 'user' that is writing something the smaller word has to come up and not the longer one. Does anybody have any idea with it?

10th Jan 2021, 11:34 AM
Dimitris Grigoriadis
Dimitris Grigoriadis - avatar
5 Answers
+ 4
Dimitris Grigoriadis , please do not duplicate posts. This does not help getting more answers. Thanks!
10th Jan 2021, 12:54 PM
Lothar
Lothar - avatar
+ 3
use the len function to know the length of a string .Then it's all about using if statement.
10th Jan 2021, 12:09 PM
The future is now thanks to science
The future is now thanks to science - avatar
+ 2
Yes, but you could provide us with your attempt first. In addition you could use at the beginning the search function to find a few similar codes, projects, questions etc.
10th Jan 2021, 12:11 PM
JaScript
JaScript - avatar
0
if I start the code like this : txt = input() word = txt.split() l = len(word) how you will complete it ?
10th Jan 2021, 1:40 PM
**🇦🇪|🇦🇪**
**🇦🇪|🇦🇪** - avatar
0
Now that you've spilt your input.... have a look at the built-in "min" function, use key=len,.......but you need to also use list slicing.
10th Jan 2021, 1:54 PM
rodwynnejones
rodwynnejones - avatar