We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,973 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Think Python - Exercise 10.7 - is_anagram.py

def is_anagram(t,u):
    if sorted(t)== sorted (u):
        return True
    else:
        return False

print is_anagram('realtor', 'rotlear') # True
print is_anagram('superpuff','local') # False
print is_anagram('alla', 'lala') # True
print is_anagram('tools', 'stool') # True
print is_anagram('double', 'trouble') # False
4
Contributors
5
Replies
2 Days
Discussion Span
2 Months Ago
Last Updated
39
Views
Question
Answered
jeremywduncan
Newbie Poster
20 posts since Feb 2013
Reputation Points: -1
Solved Threads: 1
Skill Endorsements: 0

So are you happy with this code,do you have a question?
Just to post some code without any question is not helping anyone,it's just irritating.

snippsat
Posting Shark
956 posts since Aug 2008
Reputation Points: 482
Solved Threads: 344
Skill Endorsements: 8

I am new to Python and couldn't find any other posts concerning this Exercise. Does anyone have any other suggestions besides the built-in sorted() function? I printed the Python Quick Reference by Chris Hoffman but it is dated 1995 and wasn't sure if there was a newer QR than that. I am still learning a lot of the basic coding and the last programming class I took was Turbo Pascal in 1995. This is part of my online only Object-Oriented Programming class at Trident International University. I'm finding it difficult to do some of this homework and going through the books and websites like this one is helping a lot. Sorry for not saying that before. Thank you, snippsat.

jeremywduncan
Newbie Poster
20 posts since Feb 2013
Reputation Points: -1
Solved Threads: 1
Skill Endorsements: 0

I think you made a very good effort!
But you need to let folks know what you are after.

Ene Uran
Posting Virtuoso
1,830 posts since Aug 2005
Reputation Points: 676
Solved Threads: 255
Skill Endorsements: 7

Thanks and I will be more specific in the future.

jeremywduncan
Newbie Poster
20 posts since Feb 2013
Reputation Points: -1
Solved Threads: 1
Skill Endorsements: 0
Question Answered as of 2 Months Ago by Ene Uran and snippsat

You might want to see my anagram code snippets, simplest handling one word anagrams only is here http://www.daniweb.com/software-development/python/code/285434/super-simple-one-word-anagrams

pyTony
pyMod
Moderator
6,305 posts since Apr 2010
Reputation Points: 879
Solved Threads: 986
Skill Endorsements: 26

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.3343 seconds using 2.72MB