Overview:
- The upper() method of the bytearray class creates a new bytearray consisting of uppercase ASCII characters from a bytearray of lowercase ASCII characters. Since the bytearray is a sequence of bytes only ASCII characters are allowed in a bytearray object.
- Passing of Unicode characters while creating a bytearray will lead Python to issue an error stating, “SyntaxError: bytes can only contain ASCII literal characters”.

- A bytearray is a mutable sequence of bytes and the method upper() works for the ASCII range of characters. For converting a sequence of Unicode characters e.g., Russian alphabets to uppercase, the upper() method of Python str class can be used. A Python string is an immutable sequence of Unicode characters.
Example:
|
# Example Python program that creates a # A bytearray with lowercase characters # A bytearray with uppercase characters |
Output:
|
The bytearray in lowercase: |