# Number generator

I’m making a number generator and I want forums to help me. I want the user to be able to change how big the number generator can be. right now you have to put how many digits the max can be. Here’s what I got:

``````#you need to write the whole word "yes" or "no" for it to work.
from random import randint
while True:
max_number_of_digits = 10
num_of_digits = randint(1, max_number_of_digits)
num = randint(1, int("1" + ("0" * num_of_digits)) )
print("                                                                 ")
print("                                                                 ")
print("Welcome To Number Generator.")
print("Would You Like To Get A Number?")
answer = input("Enter yes or no: ")
print(num)
print("So why did you open the program!?")
else:
print("                                             ")
print("                                             ")
``````

something wierd happend

Just so we’re clear, this will raise an error.

its to make the ouput cleaner

Those are unterminated statements. The closing quote is missing, as is the parens on the `print()` call.

The quotes are just cut off the screen

Wouldn’t empty `print()` have the same effect?

I guess that works to but besides that can you help?

You might want to work out a way to break that infinite loop. Use language that is neutral, without insulting your user.

just having fun also what do you mean break the loop

``````while True:
#code
``````

That is an infinite loop. It needs a breaking condition.

An easy way to do it, could be asking the user for another input, simply specifying the max digits wanted, and using that input instead of `max_number_of_digits`.

Happy coding!

1 Like