Articles

Program to find the longest word present in a tuple in Python

Program to find the longest word present in a tuple in Python


In the python programming article, we are going to learn

  • program to find the longest word present in a tuple in python

Program to find the longest word present in a tuple in Python

The program is as follows:

 

# Owner : TutorialsInhand Author : Devjeet Roy

names = ("Devjeet","Ajit","Bulbul","Shawriya")
print("The longest name is:",max(names))

The output of the program is as follows:

 

PS C:\Users\DEVJEET\Desktop\tutorialsInHand> python code.py
The longest name is: Shawriya

Few important tips about the program

1. In Python, we know that the max() function returns the largest number present in a list or a tuple. But the max() function can also return the longest string present in a list, if the list contains all the string elements.

2.The same process is applicable for python lists too.

 

find longest word present in a tuple in python

 


Basic Python Programs

Would you like to see your article here on tutorialsinhand. Join Write4Us program by tutorialsinhand.com

About the Author
Devjeet Roy
Full Stack Web Developer & Blockchain Enthusiast
Page Views :    Published Date : Oct 13,2022  
Please Share this page

Related Articles

Like every other website we use cookies. By using our site you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service. Learn more Got it!