Home > Blockchain >  Get values using input()
Get values using input()

Time:12-09

I'm trying to make a program that takes the length and width and print the for each observation.

I have this:

length = 0 
 width = 0

def GetValues():
    print("Lengt", i 1)
    length = int(input())
    print("width(m) ", i 1)
    width = int(input())
    return length,width

print("How many times")
Times = int(input())

for i in range(Times):
   GetValues()
   Area = length(i)*width(i)
   print('The area :', Area)

But i get TypeError: 'int' object is not callable

CodePudding user response:

Here is the solution

length = 0 
width = 0

def GetValues():
    print("Lengt", i 1)
    length = int(input())
    print("width(m) ", i 1)
    width = int(input())
    return length,width

print("How many times")
Times = int(input())

for i in range(Times):
   length, width = GetValues() # extract return values from function
   Area = length*width # just multiply them
   print('The area :', Area)
  • Related