## This program is programmed little special way to demonstrate Python ternary if from __future__ import print_function ## for python 2.6 Python 3 style print function from random import randint from sys import version print ('Your python is:\n',version) if version=='3': raw_input = input secret = randint(0,100) found = False tries=0 print('What number between 0 and 100 I am thinking') while not found: try: tries += 1 guess=int(raw_input('%i. try:' % tries)) found = guess == secret print ('Too small' if guess < secret else ('You found it with %i tries! It was %i.' % (tries,secret) if found else 'Too big') ) except ValueError: print('Input must be number')
Are you able to help answer this sponsored question?
Questions asked by members who have earned a lot of community kudos are featured in order to give back and encourage quality replies.