![]() | |
So CMPT guys.... Python Gods..... I'm trying to count the number of LETTERS/CHARACTERS in a string and not its numbers/special characters. So in a string like "abc132add" it would count 6 (only the letters) any idea how to do this? I'm not looking for a position thing because the strings can be different. |
Look for asci characters and see which of them are the letters. Then if the asci is between that range, count it as a letter |
Quote:
But neither of those work.... :okay: |
Quote:
ex. "a".isalpha() should return true, and "a".isdigit() should return false... So after you define your input... count=0 for char in input: if isalpha(char): count +=1 return count :badpokerface: Otherwise I think Messer is right in that you can use string.ascii too.. but I don't have python on this computer to play around with lol. |
Quote:
|
Quote:
:( Thanks though! Anyone know any good cmpt tutors? |
Quote:
Quote:
|
Quote:
alphabet = letters of alphabet (lowercase and uppercase) intizalize count to 0 for letters in string //Check each character in stringif letters in alphabet //if character is in the alphabet than count + 1count = count + 1return count Spoiler! |
Thanks for the effort all. Assignment closed already. I'll post up answers once they are received. |
Quote:
for i in range 1 to len(string) if string[i-1].isalpha() count += 1; |
wow so much comp sci support. anyways: summer enrollment dates released I got a March 15th 2:30 |
Quote:
|
Quote:
|
Quote:
|
Damn why are you guys so early? Mine is on the 21st. Is it because you guys are in 4th year, a lot of units accumulated, or high GPA?:badpokerface: |
Mine's on the 25th LOL daymmmmm but going to vietnam this summer, so no summer semesterr :fullofwin: |
Fuck Ever take a class that is hard, miss a midterm, add weight to your final, and realize it's fucking hard? I did. Final is worth 80%, midterm 20% Will reply back with results :fuckthatshit: |
Quote:
|
Quote:
|
anyone in econ 345 and/or 354? both midterms tomorrow.. :fuuuuu: |
^ im in 345, how u preparing for it |
just trying to do practice exams to see how well i know the material, it gets kinda confusing to be honest I haven't been paying much attention in lecture lol |
Quote:
|
Quote:
|
it's not that bad I'm just screwed because I have two exams back to back tomorrow, all the information is kind of overwhelming lol |
All times are GMT -8. The time now is 05:07 PM. | |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
SEO by vBSEO ©2011, Crawlability, Inc.
Revscene.net cannot be held accountable for the actions of its members nor does the opinions of the members represent that of Revscene.net