In The Tip calculation exercise, it wont accept:

tip = 15 / 100

But will accept

tip = 15.0 / 100

From the Python Shell I can see that 15 / 100 still returns 0.15, so I don't understand where the problem is.

In The Tip calculation exercise, it wont accept:

tip = 15 / 100

But will accept

tip = 15.0 / 100

From the Python Shell I can see that 15 / 100 still returns 0.15, so I don't understand where the problem is.

what shell? If the shell you are talking about runs python3, then yes

the problem is that in python2, a division involving two integers returns an integer, the number gets floored (round down to a integer), this division behavior was changed in python3

well, i think you just answered your own question, what python2 does isn't intuitive, so its changed in python3 to make it more intuitive

what python2 does has an advantage:

```
aList = [1,2,3]
print aList[len(aList)/2]
```

retrieving the middle value of a list, this will give a error in python3 (list indexes must be integers, not floats)

the problem is easily to solve in python3:

```
aList = [1,2,3]
print aList[len(aList)//2]
```

`//`

is floor division. Simply fix

and with a little googling, everything is findable:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.