0

I would like to solve this problem using the find function. I have been working on it using the split function because I don't understand find. If someone could show me how to do it with find, it would be awesome. Also I am getting stuck in this one part of the problem.

start = ("Please enter the starting weight of food (in lbs:ozs) = ")
answerOne = input(start).strip()
startPounds, startOunces = answerOne.split(":")
startPounds = int(startPounds)
startOunces = int(startOunces)
end = "Please enter the ending weight of food (in lbs:ozs) = "
answerTwo = input(end).strip()
endPounds, endOunces = answerTwo.split(":")
endPounds = int(endPounds)
endOunces = int(endOunces)
startPoundsO = startPounds * 16
endPoundsO = endPounds * 16
poundsO = startPoundsO - endPoundsO

This is where I am having problems.

Heres the original problem.

A monkey is being fed some food. Read in the starting weight in lbs:ozs. Also read in the ending weight in lbs:ozs (you may assume this is smaller than the starting weight. Find the difference and print out the amount of food consumed by the monkey in lbs:ozs.

Heres the data provided.

Starting weight of food (in lbs:ozs)=8:9

Ending weight of food (in lbs:ozs)=6:14

Food consumed by the monkey (lbs:ozs)=1:11

John Zwinck
  • 239,568
  • 38
  • 324
  • 436
  • 3
    `split` is perfect for this. Using `find` for this would be like using wire cutters to prepare lettuce. You can do it, but it's awkward. – Amadan Oct 06 '14 at 01:06

1 Answers1

0

Agree with @Amadan, little bit awkward :

startPounds, endsPounds = int(answer[0:answer.find(':')]), int(answer[answer.find(':')+1:len(answer)])
Yanuar Kusnadi
  • 233
  • 2
  • 7