Skip to content
Sign upLog in
← Back to Community

How to print a variable in python

Profile icon
bwoop

How do i print a variable i already defined named "money" in python?

Answered by CoolCoderSJ [earned 5 cycles]
View Answer
Voters
Profile icon
bwoop
Comments
hotnewtop
Profile icon
CoolCoderSJ

If you've already defined money, you can use this to print the variable:

print(money)

Which will print the value of money into the console.

Profile icon
bwoop

@CoolCoderSJ
thanks

Profile icon
GavinCody

how do i print 3.14159265359 as 3.14

Profile icon
bwoop

@GavinCody
probably print(3.14) but if you're talking about an already defined variable that you've defined as 3.12159265359 then I'd need more information

Profile icon
AloeBest

If you want to be fancy you can do this:

def printMoney(): global money print(money)

and anytime you want to do it:

printMoney()
Profile icon
bwoop

@AloegelhiPlaysR
ok i will keep it in mind!

Profile icon
AloeBest

Okay. Just to let you know, if you need anything made in JavaScript feel free to let me know. You can @ me on a post (but people might report it for low effort) but if you have a question for anything you can throw in a

@AloegelhiPlaysR
:)
@bwoop

Profile icon
Bookie0

@AloegelhiPlaysR
there's no semicolen after print(money);

and it's also kinda bad practice to make variables global

Profile icon
Bookie0

@AloegelhiPlaysR
this program was in Python btw...

Profile icon
AloeBest

yeah ik, i just offered to help out. I'm doing javascript requests and will make anything you want in javascript. Currently doing request #2 which is a website.

@Bookie0

Profile icon
bwoop

@AloegelhiPlaysR
html is better for a website

Profile icon
Bookie0

@AloegelhiPlaysR
hum

Profile icon
Bookie0

you need html, css, and js to make a cool website.

@bwoop

Profile icon
AloeBest

I use html, css, js for my website Request. I only do 5 website request a week unless it takes longer. JS request I can do up to 14 a week. 2 a day. Read my bio for my request times.

@bwoop

Profile icon
bwoop

@Bookie0
but if you were limited to 1 language to make a website, html would be the best choice

Profile icon
bwoop

@AloegelhiPlaysR
i am already making a website lol but thanks for the offer

Profile icon
AloeBest

TRUE! Because html allows support for css and js.

Profile icon
Bookie0

hum ¯\_(ツ)_/¯

@bwoop

Profile icon
AloeBest

Also, np! I love to help out the community.

@bwoop

Profile icon
Michael8910

money = YOURVALUE
print(money)

or if there is still an error you might need to do

global money
money = YOURVALUE
print(money)

Profile icon
Bookie0

@MikeJMS8910
it's bad practice to use global, and you can also add codeblocks + syntax highlighting by adding 3 backslashes () andpy` after them:

money = YOURVALUE print(money) or if there is still an error you might need to do global money money = YOURVALUE print(money)

Screen Shot 2020-12-18 at 12.53.05 PM