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.")`
CodePudding user response:
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")