I need help, i dont understand


#1

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)
https://www.codecademy.com/courses/python-beginner-2W5v7/0/5?curriculum_id=4f89dab3d788890003000096#

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
else:
    print 'empty'

#2

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.


#3

oh, ok i understand :smile: :sunny:


#4

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

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


#5

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