Python: Create a bytearray from a list
Python Basic: Exercise-118 with Solution
Write a Python program to create a bytearray from a list.
Sample Solution:
Python Code:
# Print a blank line for separation.
print()
# Create a list of integers called nums.
nums = [10, 20, 56, 35, 17, 99]
# Create a bytearray from the list of integers.
values = bytearray(nums)
# Iterate through the elements of the bytearray and print each element.
for x in values:
print(x)
# Print a blank line for separation.
print()
Sample Output:
10 20 56 35 17 99
Python Code Editor:
Previous: Write a Python program to prove that two string variables of same value point same memory location.
Next: Write a Python program to round a floating-point number to specified number decimal places.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://198.211.115.131/python-exercises/python-basic-exercise-118.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics