Python Forum
wont print last sentence.. - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: wont print last sentence.. (/thread-15683.html)



wont print last sentence.. - mitmit293 - Jan-27-2019

import random a = random.randint(1,99) guess = int(input('et tal..')) print while a != guess: if guess < a: print('low..') guess = int(input('gæt igen..')) elif guess > a: print('high..') guess = int(input('gæt igen')) else: print('you win') break
it does not print 'you win', it just breaks out. Why is that?


RE: wont print last sentence.. - stullis - Jan-27-2019

If you're running this is command line, it will print "you win" and immediately break ending the program. Run it in IDLE.


RE: wont print last sentence.. - aakashjha001 - Jan-27-2019

#Put the last line outside the loop as when a equals guess the loop will break.
import random
a = random.randint(1,99)
guess = int(input('et tal..'))
print
while a != guess:
if guess < a:
print('low..')
guess = int(input('gæt igen..'))
elif guess > a:
print('high..')
guess = int(input('gæt igen'))
print('You win')


This forum uses Lukasz Tkacz MyBB addons.
Forum use Krzysztof "Supryk" Supryczynski addons.