Why doesn't this work? making new variable from old ones :L



Traceback (most recent call last):
File "python", line 5, in
TypeError: 'str' object is not callable

I expected it to store a the first letter of 'original' as 'first'

pyg = 'ay'

original = raw_input('Enter a word:')

first = original(0)

if len(original) > 0 and original.isalpha():
    print original
    print 'empty'


first = original(0)

To get single character from a string we use (index operator )[] - bracket notation
You have used parentheses


ahhhh thanks, missed that


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