Python Forum
pythonroom Siblings Task
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pythonroom Siblings Task
#4
(Dec-02-2016, 02:30 AM)ichabod801 Wrote: I would look at your logic. If I have an older sibling, then I have a sibling. If I have a sibling, then I'm not an only child. Also, I can't be the oldest child if I have an older sibling.

I feel so stupid now aha, thank you. As I was in such a routine of getting the other tasks done, I wasn't using this logic. Using this code, the website said I was right;

older = 0
younger = 0

if older == 0 and younger == 0:
        print ("only child")
elif older == 0 and younger > 0:
        print ("oldest child")
elif younger == 0 and older > 0:
        print ("youngest child")
elif younger > 0 and older > 0:
        print ("middle child")
Thanks again, ichabod801!

- Rhys

(Dec-02-2016, 04:25 PM)micseydel Wrote: The way you've described the problem is incomplete. The two values aren't enough to determine the desired result you've described (except in the case of an only child).  If there is one older and one younger, "the person" isn't clearly one or the other. You could produce a list or some other collection of results though.

(Dec-01-2016, 11:47 PM)Rhysimus Wrote: 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.
Can you provide a link to the website? The full message(s) you get back? Does it expect your answer via stdout or does it have other requirements? You hard-coded the variables here, is the site supposed to provide them in some way?

Looking at your post and ichabod801's post, I figured that my logic wasn't correct. As stated above, I was in such a routine to get my tasks done that I sort of just began to lose my mind almost. The website is pythonroom.com. Essentially there are lessons in which I have to do to show the teacher that I understand.

To answer your other questions, it only tells me wrong if for example I haven't used str and int correctly, if I have mismatched open or closed parentheses and such. The variables are hard-coded, however I am able to change the numbers accordingly to see my code work on the website.

Thanks again!

- 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