Write a program that takes an integer as input, converts it to binary, and then returns the maximum number of consecutive 1’s in the binary representation.
Example:
Input: 13
Output: 2
Convert the integer to binary using Python’s built-in bin function, which will return a string. You can then split this string on ‘0’ and find the length of the longest segment of ‘1’s.
NOTEOwing to browser caching, any code input into the Trinket IDE might carry over across page refreshes or when transitioning between different questions. To commence with a clean slate, either click on the 'Reset Button' found within the IDE's Hamburger icon (☰) menu or resort to using Chrome's Incognito Mode.