Question: Python def look_say(n): return None if __name__ == __main__ : print( 'Testing look_say() for 3: ' + str(look_say(3))) print( 'Testing look_say() for 8: ' +

Python

Python def look_say(n): return None if __name__ == "__main__": print('Testing look_say() for

 def look_say(n): return None 
if __name__ == "__main__": 
 print('Testing look_say() for 3: ' + str(look_say(3))) print('Testing look_say() for 8: ' + str(look_say(8))) print('Testing look_say() for 12: ' + str(look_say(12))) 

In mathematics, the look-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 111221, 312211, 13112221, 1113213211, To generate a member of the sequence from the previous member, read off the digits of the previous member, counting the number of digits in groups of the same digit. For example: 1 is read off as "one 1" or 11 11 is read off as "two 1s" or 21 21 is read off as "one 2, then one 1" or 1211 1211 is read off as "one 1, one 2, then two 1s" or 111221 111221 is read off as "three 1s, two 2s, then one 1" or 312211 Write the function look-say that takes an integer giving which term of the look-and-say sequence we want, starting from 0, and returns a string containing that term. Term #0 is term #1 is 1 term #2 is 21 and so on. Your function must return the correct string for any non-negative integer argument. No matter how long the numbers become, the only digits that will appear are 1, 2 and 3. Examples: Function Call Return Value look-say (3) 1211 look-say (8) 31131211131221 look-say (12) 132 11 321321 112 131221 1231 1311 2221 1311 1221131 221 Note that the quotation marks displayed in the return values are there to emphasize that the return values are strings. You should not add quotation marks to your return values

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!