Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Basics Functions and Looping Functions

question why the double // when dividing why not just one?

i get that it is dividing the number of ! but still why 2, lastly why the "!" quotes around the ! it not a word and we are assigning a function why are the "" necessary only around the ! i lied my bad, this is my last one, how does the "!" * work if you count the ! its not doubled so what is the line of code saying before he shows us the def function ?

3 Answers

Its the language syntax, if you do 8 // 8 you get the result 1, if you do 8 / 8 you will get the float value, 1.0, sometimes you are working with floats (I never actually knew this until i just tried it now)

Jeff Muday
Jeff Muday
Treehouse Moderator 28,716 Points

Nick-- great answer. I upvoted it.

Elaborating further-- // is called the "double division" operator, it returns the "floor" result of a division. It conforms to the Python division operation type conversion standard.

https://www.geeksforgeeks.org/benefits-of-double-division-operator-over-single-division-operator-in-python/

Thanks for clarifying it, Nick.

he used // (i.e double division operator) because he wants to keep and use the number_of_characters in integer form....if he used /(i.e. single division operator) the number_of_characters would be converted to a float data type which will return an error(TypeError: can't multiply sequence by non-int of type 'float')

:)