Skip to content
Advertisement

Python script crashes when I input an integer

I was trying to make a simple dice in py, and I tried to make so you can change the amount of sides the dice has and if it’s left empty, to default to 6. But when I input something, it crashes.

JavaScript

I already tried changing == is, and nothing happened

JavaScript

Advertisement

Answer

One issue your code has is it is trying to use the input directly without taking care of the type.

input() returns a string, so it has to be converted to proper type before using it in randint

Try something like this.

JavaScript

input()

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement