+ 1

Can someone explain to me why this code gives me "No Output" in sololearn

def beer_song(): bottles = 99 for beer in range(0,99): print(bottles,'bottles of beer on the wall,') print(bottles,'bottles of beer,') print('Take one down, pass it around,') bottles -=1 if bottles == 1: print(bottles,'bottle of beer on the wall.') print(bottles,'bottle of beer on the wall,') print(bottles,'bottle of beer,') print('Take one down, pass it around,') bottles -= 1 if bottles == 0: print('No more bottles of beer on the wall.') print('No more bottles of beer on the wall,') print('No more bottles of beer,') print('Go to the store, buy some more,') print('99 bottles of beer on the wall.') break print(bottles,'bottles of beer on the wall.') This is the code, when I run it in Idle it runs perfectly fine but solo learn is telling me "No Output"

19th Jan 2019, 2:50 AM
Leo Hunter
Leo Hunter - avatar
4 Respostas
+ 6
Leo Hunter I think I recognize the code! It is from the book "99 Bottles of OOP" by Sandi Metz, isn't it?! 🙈🙊 Or at least, inspired by it?! 🤔 EDIT: It is written in Ruby but you're trying with Python!
19th Jan 2019, 4:48 AM
Geovanny Martínez Forero
Geovanny Martínez Forero - avatar
+ 2
Did you call your function (after the def block)? def beer_song(): # Code goes here beer_song()
19th Jan 2019, 2:58 AM
Diego
Diego - avatar
+ 2
Leo Hunter That's the way it is on the Playground. https://www.sololearn.com/Discuss/449564/?ref=app
19th Jan 2019, 4:52 AM
Diego
Diego - avatar
0
I got it to work now, but it stops at 39 bottles (time exceeded)
19th Jan 2019, 4:38 AM
Leo Hunter
Leo Hunter - avatar