halfway newb having trouble

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

halfway newb having trouble

Postby dr3311 » Mon Dec 02, 2013 8:25 pm

im making a paycheck calculater, just for some practice. i am getting an error i dont understand. i am sure its simple but i cant figure it out.

print 'total hrs', a+b+c+d+e+f+g+h+i+j = x

i am gettin a syntax error pointin to the equal sign. any help would be greatly appreciated.
Last edited by micseydel on Mon Dec 02, 2013 8:50 pm, edited 1 time in total.
Reason: First post lock.
dr3311
 
Posts: 5
Joined: Mon Dec 02, 2013 8:20 pm

Re: halfway newb having trouble

Postby micseydel » Mon Dec 02, 2013 8:53 pm

The way the = operator works in Python is, you have a variable name on the left hand side and give it the value of the expression on the right hand side. It is not Python to have it be the reverse, and you won't see an assignment (equals sign) on the same line as a print statement either. If you just drop the "=x" you should be fine.

Also, in the future, please use code tags even when you're posting a single line of code.
Join the #python-forum IRC channel on irc.freenode.net!

Please do not PM members regarding questions which are meant to be discussed publicly. The point of the forum is so that others can benefit from it. We don't want to help you over PMs or emails.
User avatar
micseydel
 
Posts: 1443
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

Re: halfway newb having trouble

Postby dr3311 » Mon Dec 02, 2013 8:56 pm

sorry, do not even answer this. i posted this before reading the post instructions. and its a stupid question anyway, i must have had a brainfart. I figured it out.

Code: Select all
a=input('wed hrs:')
b=input('thurs hrs:')
c=input('fri hrs:')
d=input('sat hrs:')
e=input('sun hrs:')
print
print
f=input('wed hrs:')
g=input('thurs hrs:')
h=input('fri hrs:')
i=input('sat hrs:')
j=input('sun hrs:')
x=a+b+c+d+e+f+g+h+i+j
print
print 'total hrs', a+b+c+d+e+f+g+h+i+j
print
print
print
print 'paycheck before taxes=',x * 8
.
dr3311
 
Posts: 5
Joined: Mon Dec 02, 2013 8:20 pm

Re: halfway newb having trouble

Postby micseydel » Mon Dec 02, 2013 8:58 pm

Thanks for following up and posting your solution!
Join the #python-forum IRC channel on irc.freenode.net!

Please do not PM members regarding questions which are meant to be discussed publicly. The point of the forum is so that others can benefit from it. We don't want to help you over PMs or emails.
User avatar
micseydel
 
Posts: 1443
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

Re: halfway newb having trouble

Postby dr3311 » Mon Dec 02, 2013 9:01 pm

thanks micseydel i have now read your post instructions here. I was trying to make that code work as soon as i woke up. I had written it at work the day before and when i got the error just figured id fix it the next day.

NEXT DAY:
woke up opened geany and looked at the code. couldnt figure out why i was getting the error.
made a cup of coffee and posted my question.
coffee sunk in and i realised my idiotic mistake.

thanks so much for your speedy answer. say i had a real problem a quick answer like that would really help.
dr3311
 
Posts: 5
Joined: Mon Dec 02, 2013 8:20 pm


Return to General Coding Help

Who is online

Users browsing this forum: Google [Bot] and 7 guests