Skip to content
Advertisement

How to turn a variable iterable?

Is there any way I can turn a variable iterable in a for loop? I am trying to make a password generator and for the for loop I use a variable which is an input number.

JavaScript

When I try to use a variable in a loop I get 'int' object is not iterable.

Advertisement

Answer

Erm… something like

JavaScript

Like this?

For the pick at random function you can look at https://docs.python.org/3/library/random.html#random.choice

Following the comments I rewrote and fixed them into something functional

JavaScript
Advertisement