Let's get started learning about these methods by looking at ` isalnum()`, which returns True if all characters in the string are alphanumeric and there is at least one character,
The `isalpha()` string method will return True if all characters in the string are alphabetic and there is at least one character
The `isascii()` string method will return True if the string is empty or all characters in the string are ASCII.
Here's an example that shows what happens with ASCII and Unicode (emoji)
The `isdecimal()` will return True if all characters in the string are decimal characters and there is at least one character,
Here's an example:
The `isdigit()` string method in #Python will return True if all characters in the string are digits and there is at least one character, False otherwise.
Digits include decimal characters and digits that need special handling
You can test a string to see if it can be an identifier using `isidentifier()`
Basically, you are testing if the string could be used as a variable or function name.
For full details on what an identifier is in #Python, see the docs:
As you might expect, `islower()` tests to see if all the characters in a string are lowercase
The `isnumeric()` string method will return True if all characters in the string are numeric characters, and there is at least one character
The `isprintable()` string method in #Python is used to check if all the characters in a string are printable or not
The `isspace()` string method in #Python will return True if there are only whitespace characters in the string and there is at least one character
Here are a few examples:
The `istitle()` string method will "return True if the string is a titlecased string and there is at least one character, for example, uppercase characters may only follow uncased characters and lowercase characters only cased ones"
The `isupper()` string method in #Python will return Return True if all cased characters in the string are uppercase and there is at least one cased character
β’ β’ β’
Missing some Tweet in this thread? You can try to
force a refresh
Formatting strings can be done several different ways in #Python.
The most popular method now are f-strings.
However, today I am going to cover using the `format()` method in a mini-thread!
ππ§΅π
The `format()` method can be used positionally. What that means is that you can have one or more empty curly braces and if you have enough arguments passed to `format()`, they will get inserted.
Here is an example:
If you pass in too few arguments to `format()`, then you'll get an exception πβ οΈ