PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, October 19, 2022

[FIXED] Why is my function not working in vscode when it works in jupyternote book?

 October 19, 2022     function, jupyter-notebook, pep, python, visual-studio-code     No comments   

Issue

I am new to python and have recently started to study it full-time. I have been using vscode to type out my code I would run the script and it would show my output in the terminal window.

However, I cannot get a lot of the functions I create to display an output in the terminal window. However, as a comparison check, I ran the same code in a Jupyter notebook and it worked perfectly fine. I also tried running this code on another laptop in vscode running it as a python file. But nothing has worked.

Here is the code running as a python file in vscode:

Running as a python file

Here is the code running in a jupyter notebook in vscode:

Running in a jupyter notebook

I apologise if I have been unclear. Do feel free to ask any questions to get a better understanding. I am a noob at this, so any help would be really encouraging. Thanks :)


Solution

Jupyter display in the console the value of the last line of code in a cell.

In normal Python scripts this does not happen. If you want to see the output in the console you need to use the print() function or similar.

so in your case:

print(capitalize_letters("mcdonald"))

or

capitalized_word = capitalize_letters("mcdonald")
print(capitalized_word)


Answered By - f-starace
Answer Checked By - Senaida (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing