What is None in Python?

Asked

Viewed 2,321 times

2

I am using the online IDE repl.it.

A part of the code has this user input

opcao = input(print('Digite:\n1- Acertei\n0-Errei\n\n='))

what gives the exit:

Digite:
1- Acertei
0-Errei

=
None

It doesn’t affect code execution, my question is:

  1. What is the "None".

  2. How to remove?

1 answer

3


None is nothing, is the lack of value. In case is printing this because the result of the function print() always is None because it is a function that only does an action and does not generate a valid result.

It is not a question of withdrawing the None, has to fix the programming error. It doesn’t make much sense to put a print() within a input().

Probably what you that is it:

opcao = input('Digite:\n1 - Acertei\n0 - Errei\n\n = ')
print(opcao)

Behold working in the ideone. And in the repl it.. Also put on the Github for future reference.

Study the functions before using it. They all have documentation of what you expect, what you do, and what works. For example: https://docs.python.org/3/tutorial/inputoutput.html, besides the links above.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.