Python Strings & Console Output


#1

https://www.codecademy.com/courses/python-beginner-sRXwR/4/1?curriculum_id=4f89dab3d788890003000096#

this is my code

Write your code below, starting on line 3!

my_string = "hello my name is josh"

print len.my_string
print my_string.upper()

this is the error
Traceback (most recent call last):
File "python", line 5, in
AttributeError: 'builtin_function_or_method' object has no attribute 'my_string'

please help


#2

my_string = "cat"
print len (my_string)
print my_string.upper()


#3

The code by @ajaxmaster75260 is the proper one @theblaster3000.
For explanation the error in your code is the the len() function used to get the length of a string takes one argument and that argument is the variable where the string is stored.
so you need to pas your variable my_string to the len() function as done by @ajaxmaster75260 i.e.
print len (my_string).
Hope this explanation helps :wink:


#4

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