i was playing around with python and was wondering why i cant print a variable thats associated with a string of text, this is what i wrote.
name = ("martim")
print name
Thanks for your help!
i was playing around with python and was wondering why i cant print a variable thats associated with a string of text, this is what i wrote.
name = ("martim")
print name
Thanks for your help!
The proper way to perform what you're attempting to do is (note the comments are just to help understanding):
# Set name to "martin"
name = "martin"
# Print the value of name
print(name)
When assigning values to variables, parentheses shouldn't be used unless you're using a function for assignment; e.g., pi = float("3.14")
. Print statements require parentheses as it is a function and the value being printed is the parameter.
I hope these few lines will help you to understand how to use variables, values and print-statement in Python 2:
>>> name = "martin"
>>> print name
martin
>>> print "name"
name
>>> print "martin"
martin
Also you can take a look at the beginner's guide for Python: https://wiki.python.org/moin/BeginnersGuide