So, quick description as to what I'm trying to do. The code would take an input from the user (a number, like 4) and generate random numbers. These numbers would then be converted to a string.
I'm using randint to generate the numbers, but I get errors when running it.
from random import *
def randomname():
ag = input("Input a number: \n")
count = int(ag)
name = []
for i in count:
num = randint(65, 126)
name.append(num)
count -= 1
print(name)
When running this code as-is, I get this error code:
Traceback (most recent call last):
File "C:/Users/Andrew/Documents/randomname.py", line 11, in <module>
randomname()
File "C:/Users/Andrew/Documents/randomname.py", line 6, in randomname
for i in count:
TypeError: 'int' object is not iterable
If anyone could provide an answer/fix to my issue I'd love it.
I'm fairly certain I can do the converting bit myself.
edit: formatting
Aucun commentaire:
Enregistrer un commentaire