Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

kasnwick Group Title

numheads=int(raw_input('Enter heads ')) numlegs=int(raw_input('Enter Legs ')) for numchik in range(0,numheads+1): numpig=numheads-numchik legstot=numchik*2+numpig*4 if(legstot==numlegs): print numchik,numpig print 'No Answer' in this code when i run the last print statement will execute even if the for loop finds a answer. But if i put the same code inside a function and replace print with return last return will execute only if there is no solution.Why is that???

  • one year ago
  • one year ago

  • This Question is Open
  1. bwCA Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    cannot understand what you are trying to describe. it is much easier for all of us if you post the code - please use a code pasting site http://dpaste.com http://pastebin.com http://...manyothers

    • one year ago
  2. rsmith6559 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    You're probably making an indentation error. What you posted should behave just as you describe it behaving.

    • one year ago
  3. Hunus Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    Well you just have print "No Answer" at the bottom of your code, you have to have some conditional like if there is an answer print the answer, else print no answer

    • one year ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.