Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # isogram.py by gauravssnl
- __author__ = "gauravssnl"
- def is_isogram( inputStr ) :
- # check type of input string first
- if type( inputStr ) == str :
- # condition for empty input string
- if inputStr.strip( ) == '' :
- return ( inputStr ,False )
- # input string is not empty
- else :
- # we need to convert all characters of input string to lower for input like "Ramr" ,"RAma"
- s = inputStr.lower( )
- # check count of each character in input string
- # if it is more than 1 ,then input string s is not isogram
- for i in s :
- if s.count ( i ) > 1 :
- return ( inputStr , False )
- # thus input string s is isogram
- return ( inputStr , True )
- else :
- raise AttributeError
- if __name__ == '__main__' :
- print( is_isogram( "abolishment") )
- print ( is_isogram( "happy" ) )
- # special case where same capital and small letters are present : string is not isogram
- print ( is_isogram( 'Ramr' ) )
- # print ( is_isogram( 105 ) )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement