S
S
Sherlock72832020-12-04 16:35:36
Python
Sherlock7283, 2020-12-04 16:35:36

Python arrays do not plow need help, what should I do?

massive = array('i', [])
from random import choice
from string import digits
string.ascii_letters # Подключение ASCII символов
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
a = 10
count = 0
while count < a:
    num_or_letter = random.randint(1, 2)
    if num_or_letter < 2:
        massive.append(random.choice(string.ascii_letters))
    else:
        massive.append(random.randint(0, 9))
    count + 1
print(massive)


Here is such a simple code I wrote, I can not solve the error that the console gives out.
File "C:\Users\mayer\Desktop\Randomize 4.0\test.py", line 16, in
massive.append(random.choice(string.ascii_letters))
TypeError: an integer is required (got type str)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
Wataru, 2020-12-04
@wataru

You create an array of ints: And you shove a character there:
massive = array('i', [])

massive.append(random.choice(string.ascii_letters))

What the interpreter tells you:
TypeError: an integer is required (got type str)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question