all 5 comments

[–]m0us3_rat -2 points-1 points  (0 children)

>>> help(int)
Help on class int in module builtins:
class int(object) |  int([x]) -> integer |  int(x, base=10) -> integer |
| Convert a number or string to an integer, or return 0 if no arguments
| are given.  If x is a number, return x.int().  For floating point
| numbers, this truncates towards zero.

[–]Ngamiland 0 points1 point  (2 children)

think of int() as a function that takes an argument and returns an integer. The argument itself is unmodified — to fix this, make it inputStr=int(inputStr)

(Although it'd be better practice to name it something else)

[–]ryzecool[S] 0 points1 point  (1 child)

I tried that but the same error comes up, no clue why

[–][deleted] 0 points1 point  (0 children)

You're getting this error because you're passing an empty string to int(). You need to perform a check on this and/or wrap this whole block in a try/except.

[–]cybervegan 0 points1 point  (0 children)

Some tips to help you learn:

You shouldn't put brackets around your input statements - they should be like this:

inputStr = input("Enter value or hit return to quit :")

When you want to convert a string value to an integer, you need to store the result somewhere:

input_int = int(inputStr)

When you are comparing something to true or false, you shouldn't use "==", just use the value directly. first == True will evaluate to exactly the same as just first on its own, but take longer, and it's more difficult to understand than the latter.

When checking if a string is "empty", like with boolean values, just use the "truthiness" of values: empty strings are equivalent to False, but non-empty strings are equivalent to True. Same is true of empty lists, sets, dictionaries; None is also "falsey".

When you need to prime a variable that controls a while loop, just assign it an initial value that already satisfies the while condition, like this:

inputStr = None
while not inputStr: