Questions tagged [isalpha]

83 questions
0
votes
1 answer

Why does my loop return a string if it is accepted in the "if" but returns a "None" once it passed through the "else"

Apologies for the vague title. I wasn't sure how to make it specific enough. I have some code that asks for a word and then turns it into a list of characters. I wanted to pass it through a loop to check in its isalpha(). When I run it. If my word…
Pigeon
  • 11
  • 1
0
votes
2 answers

logical error with isalpha() and mutiple while loop

i am trying to check if the user is putting a alpha character for the input and if they don't it prints a string. this whole program is for the user to pick if they want letter, numbers or special characters in there password. this is my code that…
Mr.IDK
  • 1
  • 3
0
votes
1 answer

How can i fix my code to ignore the spaces when recognizing special characters in a string?

I've got this method to recognize if there are any special characters in a given string, and it works just fine when the string is one word only such as 'h3llo', it will return True (there are special characters inside my string), but when i add…
ronny
  • 41
  • 7
0
votes
1 answer

Why isalpha() doesn't recognize a letter in a string?

I am new in python and I am having some problems with the isaplha() function. I would like to check whether in a variable some of the characters are letters. I have implemented a for loop that goes through all the character and check whether they…
0
votes
1 answer

Don't know what to use in this if-statement

isr = input() if (isr.isalpha() or (isr.isnumeric() and isr.isalpha())): print("You can't use a letter here.") else: isr = math.sqrt(float(isr)) print(isr) So i wanted it to detect if the isr string gonna have a letter…
Blogames
  • 3
  • 2
0
votes
2 answers

Is there a way to simplify isalpha, len function, in a while loop?

I'm a very new programmer. Just starting out in Python. Essentially I have a to write a program that accepts username input, with some validation. The username has to be between 5-10 alphabetical characters. I'm getting the code to test for the…
Neekolie
  • 23
  • 4
0
votes
3 answers

Python isalpha giving wrong results

with open("text.txt") as f: for line in f: line.isalpha() False File has only one line and contents are: "abc"
0
votes
2 answers

How to stop user from inserting characters instead of integers

Take a look a this piece of code, which is supposed to get the date of birth of a user, in the form of three variables belonging to a struct. printf("Insert date of birth in this format: dd/mm/yyyy\n"); scanf("%d/%d/%d", &user.bDay, &user.bMonth,…
Tiziano666
  • 21
  • 5
0
votes
1 answer

Reading and extracting useful data from a file with a loop fails to produce a list of values

I am reading a file with some data. I wish to divide the data into several categories and write these into files of their own (for example integers, like phone numbers; decimals; single words; and separate sentences). def data_reading(): data =…
Arthur
  • 35
  • 6
0
votes
2 answers

Does the isalpha() method in Python identify all non-alpha characters?

I have a file called messages.txt which consists of many sentences separated by line. I am attempt to exclude the lines that contain non-alpha characters (I only want those that include characters from A-Z. import re import string lines =…
Rishab Jain
  • 193
  • 1
  • 3
  • 11
0
votes
2 answers

Why am i getting a segmentation fault using scanf? I've initialized and set memory size, but still getting seg fault

Noob question, probably. I've looked through other answers, and I've tried what they've done. But I'm still getting the error every time. This is the first snippet from my caesar cipher program. #include #include #include…
morr0564
  • 53
  • 7
0
votes
1 answer

How to retain only alphabets from a string of words

Below is my code to remove all numbers and special character from a string: string = 'Date: 2008-01-04 18:08:50 -0500 (Fri, 04 Jan 2008)' words = "" for char in string: if char.isalpha(): words += char print(words) The output I get…
Swayam Shah
  • 119
  • 1
  • 8
0
votes
1 answer

isAlpha(str) is method converting Persian into Unicode characters and return true

I am trying to get data only in English language. I tried different methods like: public static boolean isAlpha(String s){ return s != null && s.matches("^[a-zA-Z]*$"); } Or StringUtils as: public static boolean isAlpha(String str){ return…
User169
  • 81
  • 7
0
votes
1 answer

Segmentation Fault and isalpha

I want to clear up my understanding of Segmentation faults while using command-line arguments and isalpha() but this particular situation confused me more. So I declared argv[1] a char * as a way around it as advised by this SO answer. However,…
0
votes
1 answer

Does the ascii code contain all non-alphabetic characters?

I would need to generate all non-alphabetic characters, punctuation, spaces, weird characters etc. Are they all those that appear in the ascii code or are there others? In python I should simply do: ''.join(map(lambda i: chr(i), range(255)))
user12102400