Output showing "None" in Terminal
Random832
random832 at fastmail.com
Mon Aug 24 16:50:09 EDT 2020
On Mon, Aug 24, 2020, at 09:12, Py Noob wrote:
> Hi!
>
> i'm new to python and would like some help with something i was working on
> from a tutorial. I'm using VScode with 3.7.0 version on Windows 7. Below is
> my code and the terminal is showing the word "None" everytime I execute my
> code.
The reason it is displaying None is because print() returns none, and you are sending that into input().
Either do:
print("Please enter distance in miles: ")
n = int(input())
# this will wait for input on the next line
or
n = int(input("Please enter distance in miles: "))
# this will wait for input on the same line as the text
The km_mi function doesn't seem to have any purpose and you can delete it and the other line further down referencing it. If this is for something like a school assignment that requires you to write a km_mi function, it's not clear from your code what the requirement is for this function.
More information about the Python-list
mailing list