Are 3.2.5.1 and 3.3.3 Compatible?

This is the place for queries that don't fit in any of the other categories.

Are 3.2.5.1 and 3.3.3 Compatible?

Postby thedovahkiin909 » Fri Dec 20, 2013 6:47 pm

So I wrote this small script (obviously learning), and I am wondering why it isn't working in 3.2.5.1 Portable. I'm getting a syntax error, which would normally make me think I did it wrong: but it works fine in 3.3.3.
Code: Select all
a = input("Please Enter a color... ")
b = input("Please Enter another color...")
c = input('Please Enter a name for multiple objects, with proper capitalization (ex. "Dogs")... ')
d = input('Please type an inane sentence (ex. "I have to poo")... ')

print()#Newline
print("Roses are " + a ",")
print(c + " are " + b + ",")
print(d)
print()#Newline

input("Press Enter to continue...")
Last edited by metulburr on Fri Dec 20, 2013 7:06 pm, edited 1 time in total.
Reason: locked
thedovahkiin909
 
Posts: 3
Joined: Fri Dec 20, 2013 6:37 pm

Re: Are 3.2.5.1 and 3.3.3 Compatible?

Postby metulburr » Fri Dec 20, 2013 7:01 pm

with basic code like this, there is no difference in the minor versions of python3.x

You are getting a syntax error because there is a syntax error:
Code: Select all
print("Roses are " + a ",")

you cannot put a variable and a string together like that
I assume you meant
Code: Select all
print("Roses are " + a + ",")


You should also utilize the format method
Code: Select all
print('Roses are {},'.format(a))
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1300
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: Are 3.2.5.1 and 3.3.3 Compatible?

Postby thedovahkiin909 » Fri Dec 20, 2013 7:08 pm

Well... I feel like quite the fool now :oops:

Thank you for the post. So how exactly does format work? I'm only in chapter 3 of "Learn to Think Like a Computer Scientist."
thedovahkiin909
 
Posts: 3
Joined: Fri Dec 20, 2013 6:37 pm

Re: Are 3.2.5.1 and 3.3.3 Compatible?

Postby metulburr » Fri Dec 20, 2013 7:14 pm

i wouldnt worry about it now then, it looks like they get into str.format() at chapter 8.16

You pretty much just plug in any data to a string without specifying its definition
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1300
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: Are 3.2.5.1 and 3.3.3 Compatible?

Postby thedovahkiin909 » Sat Dec 21, 2013 1:50 am

metulburr wrote:i wouldnt worry about it now then, it looks like they get into str.format() at chapter 8.16

You pretty much just plug in any data to a string without specifying its definition

Aaight then, thanks mate!
thedovahkiin909
 
Posts: 3
Joined: Fri Dec 20, 2013 6:37 pm


Return to General Coding Help

Who is online

Users browsing this forum: No registered users and 8 guests