Method # 1: Using
ord () + all ()
A combination of this method can be used to achieve the desired objective. In this method, we search the entire string and check for each character a value in the ASCII range.
The original string: G4G is best Is the string full ASCII? : True
Method # 2: Using
lambda + encode ()
This task can also be achieved with the above functions. In this combination, the lambda function is used to extend the size checking logic to the entire string and encode the function, check if the sizes of the original and encoded strings are the same.
The original string: G4G is best Is the string full ASCII?: True