-1

Why is "None" appearing me?

I made other code similar to that and "None" dindn't appear me. What can I do to stop appear me the "None" sentence?

first_question = str(input(print("Who do you bet for? ")))

if first_question == "tim" or first_question == "tess" or first_question == "alex" or first_question == "duck" or first_question  == "dog":

    bet = int(input(print("How much you bet? ")))

    if bet < 0:
        print("The bet can't take negative valours! ")
        bet = int(input(print("How much you bet? ")))
        while bet < 0:
            print("The bet can't take negative valours! ")
            bet = int(input(print("How much you bet? ")))

    if bet > my_money:
        print("The bet can't be above the money you have! ")
        bet = int(input(print("How much you bet? ")))
        while bet > my_money:
            print("The bet can't be above the money you have! ")
            bet = int(input(print("How much you bet? ")))

    if bet >= 0 and bet <= my_money:
        total_money = my_money - bet
LittleBlue
  • 13
  • 1
  • 1
    Possible duplicate of [Can anyone tell me why the following Python code is generating None in the output?](https://stackoverflow.com/questions/58087911/can-anyone-tell-me-why-the-following-python-code-is-generating-none-in-the-outpu) – Celius Stingher Oct 09 '19 at 14:09

2 Answers2

0

If you use print as the argument to input, then print return a value that you've not defined. Print will succeed and by doing this return None. Every functions returns something, and in the case with print, it is None.

Remove print as a start? first_question = str(input(print("Who do you bet for? "))) --> first_question = input("Who do you bet for? ")

Then you'd need to define my_money, and catch the case when the user enters something else than what's in your list, using an else-statement at the end.

Zug_Bug
  • 186
  • 10
0
  1. Your syntax for the input is wrong. Here's the correct usage:
 a = input("Enter a value")

No need to use print inside input. Correct these, everything will be fine.

  1. By default, input returns string values. So there is no need to explicitly type convert the input value to a string.
>>> a = input("Enter any value?...")
Enter any value?...10

>>> print(type(a))
<class 'str'>
Vikas Zingade
  • 134
  • 1
  • 2
  • 5