N
N
NeoLight32020-07-30 12:39:58
Python
NeoLight3, 2020-07-30 12:39:58

How to add a byte array to the end of another byte array?

There is an array of bytes (bytearray) smertlogin.

smertlogin = bytearray([0x09, 0x0b, 0x08, 0x20, 0x00, 0x04, 0x54, 0xf1, 0xa4, 0xac, 0x00, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xfe, 0xfe, 0xfd, 0xfd, 0xfd, 0xfd, 0x12, 0x34, 0x56, 0x78, 0x80, 0xff, 0xff, 0xfe, 0x63, 0x64, 0x40, 0x12, 0x87, 0xf1, 0x3d, 0x02])

There is a function in which I want to add the smertlogin array to the end of another bytearray variable:
hard_count = int(input("How many duplicates smertlogin in 1 packet? >> "))
new_smert = smertlogin
for i in range(hard_count): 
    new_smert.append(smertlogin)
    print(len(new_smert))


It throws an error

What did I do wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
milssky, 2020-07-30
@NeoLight3

you can use the extend method

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question