Reputation: 1 Apprentice
- New Members
- Active Posts:
- 12 (0.02 per day)
- 22-June 12
- Profile Views:
- Last Active:
- Jun 28 2012 08:25 PM
- OS Preference:
- Favorite Browser:
- Favorite Processor:
- Who Cares
- Favorite Gaming Platform:
- Your Car:
- Dream Kudos:
Posts I've Made
Posted 27 Jun 2012Oh, okay, thanks. I found what I was looking for. Sorry for the trivial question. I just didn't know what to search for..
Why do you "seldom like to do this"? Is using 'sleep' unconventional or sloppy in some way?
Posted 25 Jun 2012Good suggestions guys! I'll definitely check out your suggestions.
I also managed to find this, and it looks worth checking out.
Posted 23 Jun 2012I really like indie music!
Some artists that I enjoy listening to are..
Empire of the Sun
The Naked and Famous
My list is much longer, but I don't feel like typing it up
Posted 22 Jun 2012Oh, I see. Yeah, that is a bit redundant on my part. I stand corrected!
Why am I so bad?
Posted 22 Jun 2012range is exclusive, i.e. the sequence returned by range(n) will not include n. So range(1, len(numList)- 2) will not give you the index for the second to last element, so that is never checked.
PS: Is there a reason why you compare the first and last character outside the loop, instead of just looping over all the characters?
I actually adjusted the range(1, len(numList)- 2), but it still says that 990009 is a palindrome. Here is all of the code:
def palindrome(number): palindrome = True numString = str(number) numList = list(numString) numRev = numList numList.reverse() if(numList == numList[len(numList)-1]): for i in range(0, len(numList)- 1): if (numList[i] != numRev[i]): palindrome = False break else: palindrome = False return palindrome num1 = 999 num2 = 999 largestPal = 0 while(num1 > 100): while(num2 > 100): if(palindrome(num1*num2) == True): if((num1*num2) > largestPal): largestPal = num1*num2 print(largestPal) num2 = num2-1 num1 = num1-1
And to answer your PS, the intention was to save time. Why check numbers whose first and last digits aren't the same?
- Member Title:
- New D.I.C Head
- Age Unknown
- Birthday Unknown
- Reading, writing, learning (in general), tennis, running, The Real Housewives (don't judge me..), reddit (I'm not terribly active), foreign languages, etc, etc, etc..
- Years Programming:
- Programming Languages:
- Click here to e-mail me
eugenerator hasn't added any friends yet.