Home > Software design >  python terminal not outputting text
python terminal not outputting text

Time:06-26

i know its probably a duplicate but i didn't manage to find it. but anyways, every time i try to run my code in vscode, it exits normally with code=0, but it doesn't display anything at all on output. how can i fix this?

this is the simple code that im trying to run

`from datetime import datetime

odds = [ 1, 3 , 5 , 7, , 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, ]

rightThisMinute = datetime.today().minute

if rightThisMinute in odds: print("this minute seems a little odd!") else: print("not an odd minute.")`

and this is the output.

CodePudding user response:

https://stackoverflow.com/questions/62461708/exited-with-code-0-in-0-074-seconds-output-window-has-no-output-in-visual-stud#:~:text=The reason you have been,while running the python program.&text=Then open the vscode and,to get the desired results.

This question might be helpful. As the answers already point out, you might have multiple extensions running on VSCode.

Also try simply printing Hello World to check if it works.

CodePudding user response:

It is a problem with your list. It should look like this:

odds = [ 1, 3 , 5 , 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35 ]

With the list above the code works fine for me. But please read about the modulo function. You really don't need a list of odd numbers.

if rightThisMinute % 2 == 0:
   print("Even number")
else:
   print("not an even number")
  • Related