Python: Find the highest and lowest number from a given string of space separated integers
Python Basic - 1: Exercise-97 with Solution
Write a Python program to find the highest and lowest number from a given string of space-separated integers.
Sample Solution:
Python Code:
def highest_lowest_num(str1):
num_list = list(map(int, str1.split()))
return max(num_list), min(num_list)
text = "1 4 5 77 9 0"
print("Original string:", text)
print("Highest and lowest number of the said string:",highest_lowest_num(text))
text = "-1 -4 -5 -77 -9 0"
print("\nOriginal string:", text)
print("Highest and lowest number of the said string:",highest_lowest_num(text))
text = "0 0"
print("\nOriginal string:", text)
print("Highest and lowest number of the said string:",highest_lowest_num(text))
Sample Output:
Original string: 1 4 5 77 9 0 Highest and lowest number of the said string: (77, 0) Original string: -1 -4 -5 -77 -9 0 Highest and lowest number of the said string: (0, -77) Original string: 0 0 Highest and lowest number of the said string: (0, 0)
Pictorial Presentation:
Flowchart:

Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a Python program to check whether a given number is a narcissistic number or not.
Next: Write a Python program to check whether a sequence of numbers has an increasing trend or not.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join