Questions tagged [isalpha]

83 questions
3
votes
5 answers

How to count only letters in string?

I am trying to write a program that counts several elements in a string. The first one of those being letters. The assignment is part of the CS50 week 2 problem set, hence the libraries included. Using the while condition I was able to count every…
LauraT
  • 33
  • 1
  • 4
3
votes
2 answers

What is the meaning of return value of isalpha (at other ctype.h functions)?

The return value of isalpha() is 0 if the character is not alphabet and non-zero if its an alphabet. This is also the case for many other ctype.h library functions. Is there any meaning of the return type of this function? In other words, why not…
Osama El-Ghonimy
  • 335
  • 2
  • 12
2
votes
4 answers

Why can't my C function handle punctuation?

I'm trying to do a simple scrabble game in the cs50 pset Week 2 and the function, int compute_score(string word), can't handle an input that uses punctuation, even though it's roughly the same as the correct answer using less lines of code by…
LifeLong21
  • 15
  • 4
2
votes
3 answers

How do I check isalpha() for only the first 5 characters of a string?

I want to validate a PAN card whose first 5 characters are alphabets, the next 4 are numbers and the last character is an alphabet again. I can't use isalnum() because I want to check this specific order too, not just verify whether it contains both…
2
votes
2 answers

Why "ǃ".isalpha() is True but "!".isalpha() is False?

I have just found this strange behaviour parsing data from IANA. "ǃ".isalpha() # returns True "!".isalpha() # returns False Apparently, the two exclamation marks are different: In [62]: hex(ord("ǃ")) …
G M
  • 20,759
  • 10
  • 81
  • 84
2
votes
4 answers

How can you restrict user to only input alphabets in Python?

I am a beginner trying to learn Python. First question. Trying to find a way to ask users to input alphabets only. Wrote this but it doesn't work! It returns True and then skips the rest before continuing to the else clause. break doesn't work…
Zane
  • 23
  • 2
2
votes
2 answers

isalpha() function not working for spaces in string

I wrote a code so that it removes everything(like spaces and other things) other than the alphabats using isalpha() function and converts it to lower case using tolower() function. It is working fine if i don't put a space in the string but if there…
purple_tulip
  • 37
  • 1
  • 7
2
votes
1 answer

C programming: Problems reading a filetext and trying to sort out the longest word

I am beginner at coding, so I might be doing quite a few rookie mistakes here and there. We got this task in school and the goal is to sort out the longest word and print it together with the number of characters it has. I have gotten this far but…
RobinH
  • 23
  • 3
2
votes
3 answers

Python list does not have isalpha()

I tried to read a text file with this following data and state its data type: This is the data in the txt file 9yr14z1jdnh01ou8d38 , rcsfhuivhqgpgabxd, szumg5l7lyc30wimkah4, 1345, yfeporesumr, 1313.670598592, 1384.35266,…
Firdhaus Saleh
  • 189
  • 2
  • 13
2
votes
5 answers

Remove every second character (must be alphabetical or numerical) of a string without affecting spaces in python

For instance, if my initial string is "hello world! how are you? 0" I would like for the resulting string to be "hlo ol! hw r yu?". So far I have the following code: s = "hello world! how are you? 0" for char in s: if char.isalpha() == True:
2
votes
1 answer

Tilde TRUE with isalpha() returns -2 not FALSE

Playing around with isalpha(), I have noticed some strange behaviour. "a".isalpha() >>True "2".isalpha() >> False The two statements above, return what I would expect them to. However, now adding a tilde before, makes less sense. ~"a".isalpha() >>…
OD1995
  • 1,647
  • 4
  • 22
  • 52
2
votes
5 answers

remove string that contain both letters and numbers in python

I have a String c=("Snap-on Power M1302A5 Imperial,IMPRL 0.062IN") and I need to convert above string to c=("Snap-on Power Imperial,IMPRL") i.e i need to remove string that has both letters and numbers, How can I do this in python? I tried…
Ranjana Girish
  • 473
  • 7
  • 17
2
votes
2 answers

Faster way to find all words in a text file

I wrote a utility to scan a text file for all space delimited fields that contain alpha characters, it works great but is very slow because I am splitting every line into words and scanning each word, is there a faster way to do this? Thanks. Here…
iheartcpp
  • 371
  • 1
  • 5
  • 14
1
vote
1 answer

Count how many and what letters contains text

I need to count how many and what letters contains entered text. (take in account case) I`ve already done similar task with counting numbers in text: int main() { char text[255]; int count[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; …
tensshhi
  • 25
  • 3
1
vote
3 answers

isalpha giving True for some Sinhala words

I'm trying to check if a sentence only has Sinhala words (they can be nonsense words as long as they are written in Sinhala). Sometimes there can be English words in a sentence mixed with sinhala words. The thing is sometimes Sinhala words give True…
cmgchess
  • 7,996
  • 37
  • 44
  • 62
1
2 3 4 5 6