Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,158,164 members, 7,835,900 topics. Date: Tuesday, 21 May 2024 at 05:08 PM

Help With Python Program (simple While Loop) - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Help With Python Program (simple While Loop) (1907 Views)

A Python Program To Check The Risk Of Corona Virus. / Help! How To Make Your Java Or Python Program Become A Real Android App? / How To Run Python Program On Android (2) (3) (4)

(1) (Reply) (Go Down)

Help With Python Program (simple While Loop) by hegelian: 8:38am On Oct 15, 2016
can you guys please check while this python program aint running beyound the print(plugged it in) expression??....am just a begginner

#simplewhile loop program
print('please help my computer is not coming up')
rabiu = False
while not rabiu:
print('system help: does the computer make any sound?')
choice = input('or the fan workind?(y/n): ')
if choice == 'n':
choice = input('system help: is the computer plugged in (y/n) :')
if choice == 'n':
print('plugged it in')
else:
choice = input('system help: is the computer switched on (y/n): ')
if choice == 'n':
print('switched in on')
else:
choice = input('system help: is the fuse ok (y/n): ')
if choice == 'n':
print('system help: replace the swtich and switched it on')
else:
rabiu = True
print('system help: contact system engineer for repair')

else:
rabiu = True
print('contact technician for answer')
Re: Help With Python Program (simple While Loop) by 4kings: 12:13pm On Oct 15, 2016
Your code is syntactically correct but not logical.
You should give decisions for different or wrong responds e.g y or int
Apart from that nothing is wrong, except maybe ur spacing.

Re: Help With Python Program (simple While Loop) by Nobody: 10:02pm On Oct 15, 2016
The poster above me is right about your indentation.
At the end of the screenshot, you add
else:
print "Invalid response"
continue

A feedback would be nice

1 Like

Re: Help With Python Program (simple While Loop) by hegelian: 7:05am On Oct 16, 2016
thank you guys.....am studying the correction now
Re: Help With Python Program (simple While Loop) by hegelian: 7:16am On Oct 16, 2016
Gaara101:
The poster above me is right about your indentation.
At the end of the screenshot, you add
else:
print "Invalid response"
continue

A feedback would be nice

am not at break statement yet...am still stucked at the nested loop...but am looking into it though...thanks very much
Re: Help With Python Program (simple While Loop) by Nobody: 10:33am On Oct 16, 2016
hegelian:


am not at break statement yet...am still stucked at the nested loop...but am looking into it though...thanks very much
I shouldn't have included the break statement.
Any line that has a break statement, replace with rabiu = True
Re: Help With Python Program (simple While Loop) by Ihinmi(m): 1:38am On Oct 26, 2016
Gaara101:
The poster above me is right about your indentation.
At the end of the screenshot, you add
else:
print "Invalid response"
continue

A feedback would be nice

please which version should I use as a starter python 3 or 2. Thanks.
Re: Help With Python Program (simple While Loop) by Nascimento(m): 6:50am On Oct 27, 2016
Ihinmi:


please which version should I use as a starter python 3 or 2. Thanks.

Use any version. The version doesn't matter. Though I'd recommend python 3, because it's the future. The main thing is to know how to solve problems in python.

1 Like

(1) (Reply)

Start Your Own Software Company (micro-isv) / I Can't Access Facebook Anymore / Co-creation Hub Nigeria Announces Membership Plans, Go Get Yours

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 13
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.