Getting Different Result Tutorial - 13 - Return Values

+1 Rafal Fila · January 19, 2017
Hi I did everything like in the video but I don't get numbers with decimals and my punctuation  are showing.

Code:


def allowed_dating_age(my_age):
   girls_age = my_age / 2 + 7
   return girls_age


for my_age in range(15, 60):
   buckys_limit = allowed_dating_age(my_age)
   print ("His age is: ", my_age,"His limit is: ", buckys_limit,)

 Example of the result for me:

('His age is: ', 15, 'His limit is: ', 14)
('His age is: ', 16, 'His limit is: ', 15)
('His age is: ', 17, 'His limit is: ', 15)
('His age is: ', 18, 'His limit is: ', 16)
('His age is: ', 19, 'His limit is: ', 16)
('His age is: ', 20, 'His limit is: ', 17)
('His age is: ', 21, 'His limit is: ', 17)
('His age is: ', 22, 'His limit is: ', 18)
('His age is: ', 23, 'His limit is: ', 18)
('His age is: ', 24, 'His limit is: ', 19)
('His age is: ', 25, 'His limit is: ', 19)

Now what should happen based on the video is this:
His age is: 17 His limit is: 15.5 #etc.

I don't see what i'm doing wrong.

Post a Reply

Replies

Oldest  Newest  Rating
0 Anuj Bansal · April 23, 2017
i ran the same/images/forum/upload/2017-02-02/9d2b0592ce2796837a8f163e8509935e.png program and got the perfect result. there must be some problem with your compiler
0 Malga Golubska · April 23, 2017
Hi Rafal,

In line: for my_age in range(15,60) you miss an interval. Add 1, (i.e. range(15,60,1)), and you should get correct answers. Otherwise you get the round down values

Cheers 
0 Malga Golubska · April 23, 2017
add 1 interval to the range, like range(15,60,1)
  • 1

Python

118,310 followers
About

This section is all about snakes! Just kidding.

Links
Moderators
Bucky Roberts Administrator