Advertisement
user_137

List Comprehension

Feb 8th, 2013
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.24 KB | None | 0 0
  1. try:
  2.     value = max(x for x in (float(raw_input('Enter a number: ')) for y in xrange(10)) if x % 2 == 1)
  3.     print 'The highest number was', value
  4. except ValueError:
  5.     print "There was no odd number or a non-numeric value was entered."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement