Python output don't show in CMD
Question:
If I run this script in CMD (or Git Bash – doesn’t matter) using python name.py
, output will show only hello
and not the return value. Why is that? I tried to reinstall python, add PATH, uninstall Anaconda and install only python from official website. Code is working fine in jupyter notebook.
def to_jaden_case(string):
return ' '.join(word.capitalize() for word in string.split())
to_jaden_case("How can mirrors be real if our eyes aren't real")
print("hello")
Answers:
You need to print the return value
def to_jaden_case(string):
return ' '.join(word.capitalize() for word in string.split())
print(to_jaden_case("How can mirrors be real if our eyes aren't real"))
print("hello")
If I run this script in CMD (or Git Bash – doesn’t matter) using python name.py
, output will show only hello
and not the return value. Why is that? I tried to reinstall python, add PATH, uninstall Anaconda and install only python from official website. Code is working fine in jupyter notebook.
def to_jaden_case(string):
return ' '.join(word.capitalize() for word in string.split())
to_jaden_case("How can mirrors be real if our eyes aren't real")
print("hello")
You need to print the return value
def to_jaden_case(string):
return ' '.join(word.capitalize() for word in string.split())
print(to_jaden_case("How can mirrors be real if our eyes aren't real"))
print("hello")