Python Forum
Strings containing both symbols and letters
Thread Rating:
  • 2 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Strings containing both symbols and letters
#11
oh do not worry thanks i did not input my own variable, thank you so much for your help!

(Apr-04-2017, 09:24 PM)zivoni Wrote: For what test_string and symbols?
oh do not worry i did not input my own variable, thank you so much for your help!
Reply
#12
Hello! You can find all of these 'symbols' as predefined strings in string module.

import string

print(string.puntualtion)
print(string.ascii_letters)
print(string.digits)
Output:
'!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~' 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' '0123456789'
These are from the first 128 or as they are called ascii symbols. The extended ascii includes even more. There are utf-8, utf-16, utf-32 and bunch of regional country codes. So, for simple tasks as your ascii works but if you have to expand the boundaries of a concept to include the rest it becomes a "bit" messy.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#13
The tests we always made when there was no utf,
was as follows:

all special characters -- if hex value of character (ASCII) is one of the following,
  • < 30 special
  • 3A - 40 special
  • 5B - 60 special
  • > 7A special

if character value hex was between 30 and 7E hex, it was printable
Reply
#14
Hi you can use my code to find wether a string have letters or not ...


stri = 'qwerty'

if not stri.isalnum():
   print "string have symbols"
else:
    print "string don't have symbols"
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python script that deletes symbols in plain text nzcan 3 701 Sep-05-2023, 04:03 PM
Last Post: deanhystad
  Trying to understand strings and lists of strings Konstantin23 2 767 Aug-06-2023, 11:42 AM
Last Post: deanhystad
  Splitting strings in list of strings jesse68 3 1,777 Mar-02-2022, 05:15 PM
Last Post: DeaD_EyE
  cyrillic symbols in tables in reportlab. hiroz 5 11,476 Sep-10-2020, 04:57 AM
Last Post: bradmalcom
  Unexpected output: symbols for derivative not being displayed saucerdesigner 0 2,058 Jun-22-2020, 10:06 PM
Last Post: saucerdesigner
  Replacing symbols by " Tiihu 1 1,883 Feb-13-2020, 09:27 PM
Last Post: Larz60+
  How do I delete symbols in a list of strings? Than999 1 2,288 Nov-16-2019, 09:37 PM
Last Post: ibreeden
  Finding multiple strings between the two same strings Slither 1 2,523 Jun-05-2019, 09:02 PM
Last Post: Yoriz
  lists, strings, and byte strings Skaperen 2 4,233 Mar-02-2018, 02:12 AM
Last Post: Skaperen
  Python symbols AND letters gullidog 1 3,504 Apr-05-2017, 10:13 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020