Python Forum
pythonroom Siblings Task
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pythonroom Siblings Task
#1
Hello everyone, I'm currently having trouble doing a task on the website 'pythonroom' in the 'Branching' lesson. For those who don't know what pythonroom is, essentially we use it in class and in our off time to increase our knowledge of Python. The task in which I have been having trouble with is this;

Given the number of older and younger siblings, print
  • only child if the person has no siblings
  • oldest child if the person only has younger siblings
  • youngest child if the person only has older siblings
  • middle child if the person has both younger and older siblings
I have tried to do this task;

older = 0
younger = 0

if older == 1 and younger == 0:
           print ("only child")
elif older == 0 and younger == 1:
           print ("only child")
elif older == 1 and younger > 0:
           print ("oldest child")
elif younger == 1 and older > 0:
           print ("youngest child")
elif older > 0 and younger > 0:
           print ("middle child")
elif older == 0 and younger == 0:
           print ("only child")
However the website says I am wrong, with no comment on what I haven't done correctly (it usually tells me for example if I have not defined a variable). If anyone of you have the ability to possibly help me, I'd be forever thankful.

- Rhys
Reply


Messages In This Thread
pythonroom Siblings Task - by Rhysimus - Dec-01-2016, 11:47 PM
RE: pythonroom Siblings Task - by ichabod801 - Dec-02-2016, 02:30 AM
RE: pythonroom Siblings Task - by Rhysimus - Dec-02-2016, 05:11 PM
RE: pythonroom Siblings Task - by micseydel - Dec-02-2016, 04:25 PM
RE: pythonroom Siblings Task - by Larz60+ - Dec-02-2016, 09:09 PM
RE: pythonroom Siblings Task - by Rhysimus - Dec-03-2016, 01:30 PM
RE: pythonroom Siblings Task - by Larz60+ - Dec-03-2016, 09:38 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020