473,320 Members | 1,939 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Print/ String variables

Hi,

Very basic question, as I am absolute greenhorn.

When I run this code:

first_name='Math'
last_name='Speak'
print (first_name, last_name)

and the output looks like:
('Math','Speak')

where as I was expecting:
Math Speak

Is it to do with the version on my mac:2.7.1, where as the book am referring to recommends 3.2.2?

Thanks
Feb 25 '12 #1
1 2168
Smygis
126 100+
In python 2.7 print (first_name, last_name) print the representation of the truple (first_name, last_name). If you remove the parentheses it will print the strings first_name and last_name.

In python 2.x print is a statment and does not use parentheses.

In python 3.x print is a function and requires parentheses.
Feb 25 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Balaji | last post by:
Hello Eveybody, I have written a method which prints the prefix notation of any expression. here is the method... def PrintPrefix(expr): if expr.__class__==E: print expr.operator,...
4
by: ykz | last post by:
what format shall i use to print clock_t variables? i tried %f, %i, %S or %M(seconds or minutes, as said in K&R2 book), all seem not to work. the code is like: #include <time.h> clock_t t1,...
2
by: John Wildes | last post by:
hello I was wondering if someone could point me in the direction of information on using app.config to store string variables. I have a couple of variables that store path information for file...
7
by: Thirsty Traveler | last post by:
I have a question regarding the use of guery string variables. I understand this can be a security risk subject to "brute force" attacks. Is this true and, if so, what is the proper way to handle...
2
by: Wally | last post by:
Dim var1 as String Dim var2 as String var1="message1" var2="message2" how do I join the two string variables?
6
by: johnny | last post by:
How do I join two string variables? I want to do: download_dir + filename. download_dir=r'c:/download/' filename =r'log.txt' I want to get something like this: c:/download/log.txt
2
by: Peted | last post by:
Hi im sending this string to a device String cmd = ""N1\x0D") this device needs the esc \x0D on the end where you see it After i have sent this string i want to print it our to a rich...
11
by: julie.siebel | last post by:
I'm working on a rather complex booking system for building European trips, in a combination of SQL/VBScript/Javascript. There are tons of query string variables that get passed back and forth...
38
by: ssecorp | last post by:
char* reverse(char* str) { int length = strlen(str); char* acc; int i; for (i=0; i<=length-1; i++){ acc = str; } return acc; }
0
by: ghjk | last post by:
I'm using jsp. I want to print string array values . How can I do that? please help me. This is my code. ArrayList settings = (ArrayList)session.getAttribute("settingList");
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.