I need help, i dont understand


i dont understand what means .isalpha() and why should we put it in the script, basicaly i dont understand the entire script, can i have some help with this please? :slight_smile: ( i didnt wrote this script myself)

pyg = 'ay'

original = raw_input('Enter a word:')
if len(original) > 0 and original.isalpha():
    word = original.lower()
    first = word[0]
    new_word = word + first + pyg
    new_word = new_word[1:len(new_word)]
    print new_word
    print 'empty'


The .isalpha() checks any input entered, by the enduser, is a letter or string of letters. If the enduser enters "5" then code displays "empty" to signal the enduser to enter something different.


oh, ok i understand :smile: :sunny:


word = raw_input("Enter a word:")
if len(word) > 0 and word.isalpha():
word = (word + word[0] + "ay")[1:].lower().title()
print word
print "crap your pants"

Why make it so complicated? You can be modifying the input along the way without bringing in new objects


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