Python Forum
Triangle function program
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Triangle function program
#3
Your indentation is way off

When you define a function all of the code in that function must be indented. The first line that unindents ends the function's block of code. Is all of this code supposed to be in your function?

You also missed the requirement of collecting the variables and passing them into the function as parameters.

Here is an example of a function that takes a parameter:
def plus_one(num_input): # Parameters go in parentheses 
    incremented = num_input + 1
    # Any other code for this function must be indented like this
    # As ichabod801 said it must all come before the return statement as well
    return incremented

# Since this code is not indented it is not part of the function
age = int(input("What is your age: ")) # Collect your variable
next_years_age = plus_one(age) # Send variable into the function and store the result
print("our age next year will be", next_years_age) # Use the result produced by the function
Try again and post your results
Reply


Messages In This Thread
Triangle function program - by m8jorp8yne - Dec-13-2019, 09:57 AM
RE: Triangle function program - by ichabod801 - Dec-13-2019, 02:48 PM
RE: Triangle function program - by Clunk_Head - Dec-13-2019, 05:24 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to write a recursion syntax for Sierpinski triangle using numpy? Bolzano 2 3,887 Apr-03-2021, 06:11 AM
Last Post: SheeppOSU
  Print user input into triangle djtjhokie 1 2,393 Nov-07-2020, 07:01 PM
Last Post: buran
  Tkinter - The Reuleaux Triangle andrewapk 1 1,966 Oct-06-2020, 09:01 PM
Last Post: deanhystad
  Python - networkx - Triangle inequality - Graph Nick_A 0 2,111 Sep-11-2020, 04:29 PM
Last Post: Nick_A
  Print triangle using while loop tuxandrew 3 4,948 Dec-05-2019, 07:17 PM
Last Post: micseydel
  Intersection of a triangle and a circle Gira 3 3,631 May-19-2019, 06:04 PM
Last Post: heiner55
  Draw isosceles triangle fen1c5 4 12,925 Jul-07-2018, 10:20 AM
Last Post: fen1c5
  Pascal's triangle nvakada 5 4,629 May-01-2018, 02:44 AM
Last Post: Skaperen
  Object oriented area of a triangle xterakojede 2 8,954 Apr-20-2018, 01:42 PM
Last Post: xterakojede
  Turtle drawing Right Triangle Zatoichi 3 5,737 Feb-26-2018, 12:24 AM
Last Post: Zatoichi

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020