Python prefers EAFP over checking types (LBYL). Write a standalone function `print_length(obj)` that wraps `print(len(obj))` in a try-except block. Catch `TypeError` and print ‘No length’. Pass the string ‘Hello’ and then the integer `123` to it.
None
Print the length of the string, then 'No length' for the integer.
None
5
No length
Instead of checking if an object supports a method (like __len__), Python encourages trying to execute it and catching the exception if it fails.
def print_length(obj):
# Write try-except logic here
pass
if __name__ == '__main__':
print_length('Hello')
print_length(123)Embedded systems rely on efficient low-level programming to interact directly with hardware. In this course, you will learn how to write practical Embedded C programs used in real microcontroller-based systems. Rather than focusing only on theory, this course follows a practice-driven approach. Each lesson includes hands-on coding exercises that simulate real firmware development tasks used