Below script will take the list of integers and find and print the largest number. Here we taking the input as a space separated integers and then using split() method to convert them to a list of integers.
Code:
Execution:
Code:
def findLargest(numList): max = numList[0] for num in numList: if num > max: max = num return max print 'Enter the list of numbers Seperated by Space:' userInput = raw_input() numlist = [int(n) for n in userInput.split()] print 'Largest Number : {0}'.format(findLargest(numlist))
Execution:

No comments:
Post a Comment