forked from Jadu07/CodeFlex
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added code for finding the largest element of list provided to the fu…
…nction
- Loading branch information
Showing
1 changed file
with
16 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
def largest_number_in_list(list1): | ||
largest_number = 0 | ||
for i in list1: | ||
if i > largest_number: | ||
largest_number = i | ||
return largest_number | ||
|
||
|
||
def main(): | ||
user_numbers = input("Enter elements of list separtaed by spaces : ").split(" ") | ||
user_list = [float(elem) for elem in user_numbers] | ||
largest_value = largest_number_in_list(user_list) | ||
print(f"\nThe largest number in the list {user_list} is {largest_value}.") | ||
|
||
if __name__=='__main__': | ||
main() |