I have to add inputs just in case i have up to nine lines that i need to add feet values too. but im curious if i only have 5 lines to input is there a way to bypass the other inputs cause if i in put zero it has negative affects on the outcome.

So i had to add this to change it back for me which id rather be able to by pass it some how with my first input of how many lines of fence. also can yall let me know if im able to tighten up my code a bit.

if Line1 == 0:
    Line1 = 8
if Line2 == 0:
    Line2 = 8
if Line3 == 0:
    Line3 = 8
if Line4 == 0:
    Line4 = 8
if Line5 == 0:
    Line5 = 8
if Line6 == 0:
    Line6 = 8
if Line7 == 0:
    Line7 = 8
if Line8 == 0:
    Line8 = 8
if Line9 == 0:
    Line9 = 8
fenceLines = int(input("How many lines of fence? "))
Line1 = int(input("Enter line one lineal feet. "))
Line2 = int(input("Enter line two lineal feet. "))
Line3 = int(input("Enter line three lineal feet. "))
Line4 = int(input("Enter line four lineal feet. "))
Line5 = int(input("Enter line five lineal feet. "))
Line6 = int(input("Enter line six lineal feet. "))
Line7 = int(input("Enter line seven lineal feet. "))
Line8 = int(input("Enter line eight lineal feet. "))
Line9 = int(input("Enter line nine lineal feet. "))
cornerPosts = int(input("How many corner posts? "))
endPosts = int(input("How many end posts? "))
gatePosts = int(input("How many gate posts? "))


if Line1 == 0:
    Line1 = 8
if Line2 == 0:
    Line2 = 8
if Line3 == 0:
    Line3 = 8
if Line4 == 0:
    Line4 = 8
if Line5 == 0:
    Line5 = 8
if Line6 == 0:
    Line6 = 8
if Line7 == 0:
    Line7 = 8
if Line8 == 0:
    Line8 = 8
if Line9 == 0:
    Line9 = 8
    
Linea = round(Line1 / 8 - 1,0) 
Lineb = round(Line2 / 8 - 1,0) 
Linec = round(Line3 / 8 - 1,0) 
Lined = round(Line4 / 8 - 1,0)  
Linee = round(Line5 / 8 - 1,0)   
Linef = round(Line6 / 8 - 1,0)  
Lineg = round(Line7 / 8 - 1,0) 
Lineh = round(Line8 / 8 - 1,0) 
Linei = round(Line9 / 8 - 1,0)

x = 0                                      
if fenceLines == 1:
    x = 64
if fenceLines == 2:
    x = 56
if fenceLines == 3:
    x = 48
if fenceLines == 4:
    x = 40
if fenceLines == 5:
    x = 32
if fenceLines == 6:
    x = 24
if fenceLines == 7:
    x = 16
if fenceLines == 8:
    x = 8
if fenceLines == 9:
    x = 0
    
fenceLength = Line1 + Line2 + Line3 + Line4 + Line5 + Line6 + Line7 + Line8 + Line9 - x 

eightGate = int(input("How Many 8 foot gates."))
fourGate  = int(input("How Many 4 foot gates."))

post = 0
Price = 0
eightHinges = 0
eightGateLatch = 0
eightGateStop = 0
eightScrewGate = 0
eightEightFooters = 0
eightTenFooters = 0

if eightGate == 0:
    Price = 0
    eightHinges = 0
    eightGateLatch = 0
    eightGateStop = 0
    eightScrewGate = 0
    eightEightFooters = 0
    eightTenFooters = 0
    post = 0
if eightGate == 1:
    Price = 100
    eightHinges = 4
    eightGateLatch = 1
    eightGateStop = 1
    eightScrewGate = 24
    eightEightFooters = 4
    eightTenFooters = 2
    post = -1
if eightGate == 2:
    Price = 200
    eightHinges = 8
    eightGateLatch = 2
    eightGateStop = 2
    eightScrewGate = 48
    eightEightFooters = 8
    eightTenFooters = 4
    post = -1
if eightGate == 3:
    Price = 300
    eightHinges = 12
    eightGateLatch = 3
    eightGateStop = 3
    eightScrewGate = 72
    eightEightFooters = 12
    eightTenFooters = 6
    post = -1
if eightGate == 4:
    Price = 400
    eightHinges = 16
    eightGateLatch = 4
    eightGateStop = 4
    eightScrewGate = 96
    eightEightFooters = 16
    eightTenFooters = 8
    post = -1

price = 0
fourHinges = 0
fourGateLatch = 0
fourScrewGate = 0
fourEightFooters = 0
fourTenFooters = 0

if fourGate == 0:
    price = 0
    fourHinges = 0
    fourGateLatch = 0
    fourScrewGate = 0
    fourEightFooters = 0
    fourTenFooters = 0
if fourGate == 1:
    price = 50
    fourHinges = 2
    fourGateLatch = 1
    fourScrewGate = 12
    fourEightFooters = 2
    fourTenFooters = 1
if fourGate == 2:
    price = 100
    fourHinges = 4
    fourGateLatch = 2
    fourScrewGate = 24
    fourEightFooters = 4
    fourTenFooters = 2
if fourGate == 3:
    price = 150
    fourHinges = 6
    fourGateLatch = 3
    fourScrewGate = 36
    fourEightFooters = 6
    fourTenFooters = 3
if fourGate == 4:
    price = 200
    fourHinges = 8
    fourGateLatch = 4
    fourScrewGate = 48
    fourEightFooters = 8
    fourTenFooters = 4

linePosts = Linea + Lineb + Linec + Lined + Linee + Linef + Lineg + Lineh + Linei + cornerPosts + endPosts + gatePosts + post
concrete = round(linePosts * 0.75,0)
Boards = round(fenceLength * 12 / 5.5,0)
nails = round(Boards * 6,0)
stringers = fenceLength / 8 * 3  
sixteenFoot = (fenceLength  / 16) * 3 
Nails = linePosts * 18 
totalMaterialLabor = fenceLength * 10.00 + price + Price
totalLabor = fenceLength * 2.50

print ("Fence is", fenceLength , "lineal feet.")
print ("You need", linePosts , "posts.")
print ("You need", concrete, "bag(s) of 80 lb Quickcrete.")
print ("You need", Boards, "Fence boards.")
print ("You need", stringers + eightEightFooters + fourEightFooters, "8 footers.")
print ("You need", eightTenFooters + fourTenFooters, "Ten footer(s) for gate(s).")
print ("You need", nails, "1-7/8 in. Galvanized ring shank nails.")
print ("You need", Nails, "Three in. galvanized ring shank nails.")
print ("You need", eightGateLatch + fourGateLatch, "Gate latch(es).")
print ("You need", eightHinges + fourHinges, "Gate hinge(s).")
print ("You need", eightGateStop, "Gate stop(s).")
print ("You need", eightScrewGate + fourScrewGate, "Three inch screws.")
print ("Estamated cost is $", totalLabor + price + Price, "or $", totalMaterialLabor, " for materls and labor.")

Your should use lists (maybe dictionary) and loops. Looks like you need to dig into this:
http://docs.python.org/tutorial/controlflow.html#for-statements

You can then tighten your code around 90% by doing things like:

fenceLines = []
for linenum in range(int(input("Enter number of lines of fence. "))):
    fenceLines.append(int(input("Enter line %s lineal feet. " % linenum)))

Preferably you should add also try..except blocks for cases user do not input ints. Then the inputs must be separated from inside the other statement and the try..except should be put in while loop.

Check out this my post on numeric checking: http://www.daniweb.com/forums/post1294983.html#post1294983

Here is example on input in Python2 (replace raw_input with input to use in Python3 and put parenthesis around printed strings)from snippsat:
http://www.daniweb.com/forums/post1221089.html#post1221089

Im trying to figure how to incorporate into the rest but i first want to understand what you showed me, also the lines of fence starts with zero and i looked all over to change it and tried but dont know where to place it so it starts at 1 instead of zero, range(1,10)

Also the %s and the % I'm trying to get comfortable with as the % gets the remainder in one instance but I'm not sure how it works here.

Also please explain the append .
Thanks

I believe, you don't need a forum, but some books to study from...
Hope the following links help:
thread1
python books

for the IF statement, I would use a dictionary pair. One statement.

You can/should use a dictionary for the values, although the code you have is fine if it works and you understand it. An example:

## replace the later code with a dictionary

# A dictionary of lists.  List elements are
# position 0=price,  1=hinges,  2=latch,  3=stop
#          4=screw gate,  5=eight foot,  6=ten foot,  7=post
eight_gate_dict ={}
eight_gate_dict[1] = [100, 4, 1, 1, 24, 4, 2, -1]
## and so forth for the others
print "gate type 1"
print "     price =", eight_gate_dict[1][0]
print "     screw gate =",eight_gate_dict[1][4]
#
# which replaces
if eightGate == 1:
    Price = 100
    eightHinges = 4
    eightGateLatch = 1
    eightGateStop = 1
    eightScrewGate = 24
    eightEightFooters = 4
    eightTenFooters = 2
    post = -1

thanks that helps a lil more.

How would i get the input out of this

fenceLines = []
for linenum in range(int(input("Enter number of lines of fence. "))):
    fenceLines.append(int(input("Enter line %s lineal feet. " % linenum)))

i used fenceLines[0 , 7]

but returns an TypeError: list indices must be integers, not tuple

I actually learned alot about this lil code but still cant understand how to take the information from wha i input to where i can use it, thanks.

Like this?

for item in fenceLines:
    print item

or

for i in range(len(fenceLines)):
    print fenceLines[i]

Cheers and Happy coding

well im not really sure because this is his code and i didnt make it up

fenceLines = []
for linenum in range(int(input("Enter number of lines of fence. "))):
    fenceLines.append(int(input("Enter line %s lineal feet. " % linenum)))

All i wanted it to do is since there can be any number of fence lines, the user can input the number of lines say from 1 to 8 or whatever and only ask the linear foot of each line.

example:
How many fence line? 5
Enter line 1 linear feet.
Enter line 2 linear feet.
Enter line 3 linear feet.
Enter line 4 linear feet.
Enter line 5 linear feet.

Then be able to take line 1 input and divide it by 8 - 1
do the same thing for line 2, line 3, line 4, line 5.

Then add all those up

To get the total posts for the job.

Also want to be able to add line 1 though line 5 to get a total linear feet.

But if the user only inputs 3 lines of fence i only want line 1 , line 2, line 3
and do the same thing .

Thanks

Print the list fenceLines. It should contain the length of each line which you can add up or do whatever else you want. Add you probably want to use linenum+1 so it starts with one instead of zero.

fenceLines = []
for linenum in range(int(input("Enter number of lines of fence. "))):
    fenceLines.append(int(input("Enter line %s lineal feet. " % linenum+1)))

I do not want to do all your code for you but here is some more idea without formulas and only first things to show the principle of one way of doing things in loop (taking input out of inside function, where it can not be saved for use in other statements):

all_things = [] # prefered naming in Python (PEP8)
suplies = ('lines of fence', 'posts', '8 foot gates', '4 foot gates')

for suply in suplies:
    items = []
    number = int(input("Enter number of %s: " % suply))
    if not suply.startswith('lines '): # only number
        all_things.append((number,))
    else:
        for linenum in range(number):
                items.append(float(input("Enter size of line number %s in lineal feet. " % (linenum+1) ) ))
        all_things.append(items)

print zip(suplies, (sum(thing) for thing in all_things))

Man all this reading i have done and i wouldn't ever even be able to come up with that.

I think the hardest part of learning this language is being able take the basics of what you read and put them into context.

Maybe i need to read something that has examples of code and explains what it does.

I been reading python 3 for absolute beginners.

you guys have a reference to look up or is all this in memory and how long have ya'll been doing this to come up with stuff and what way did you guys learn, college, self taught. Is it best to read all you can then start trying programs or is it best to make some as you go along, starting easy then get harder.

Ok i found a good topic on lists thanks for setting me in the right direction.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.