0
for resultparameter in urine_dict ['patientresultslist']:
    #start by assigning each of the pieces of daa within parameter line
    resulparalist = resultparameter.split(';')
    reportstring = reportstring + vet.setwidth(resultparalist[0], 8) + lineterm + lineterm
    vert.setwidth(resultparalist[1[,10) + vet.setwidth(resultpatientlist)
    if config['Bargraph'].lower() == 'yes':
        reportstring = reporttring + vet.bargraph(resultparameterlist)

    return reportstring

when I click to run it gives me an error to say the return is outside of function anyone can tell where I am making this error.

Kallz
  • 3,244
  • 1
  • 20
  • 38
wasima
  • 1
  • 4
  • 2
    because there is no function? function is defines using `def` in python – Radek Hofman Aug 14 '17 at 10:17
  • 1
    Show your actual indentation and any function defintion – Chris_Rands Aug 14 '17 at 10:17
  • 1
    Did you mean to `print(reportstring)`? – cs95 Aug 14 '17 at 10:18
  • there were no errors with this code up until now, so i dont know what happened for it to give me an error, also i have been having alot of issues with indentation, when i indent it it says its an error, so when i take indentation off its no longer an error, and yes i guess i want it to print the string it receives – wasima Aug 14 '17 at 10:20
  • Simply use `print reportstring` or `print(reportstring)`, then, if you're not defining a function. – Leszek Kicior Aug 14 '17 at 10:22

2 Answers2

0

Unless you are showing us only part of your code, that is because a return statement can only be used in a function, it simply won't work with if statements. Here's an example on how it works in a function. Also, read this.

def return_example():
    return 'Hello, world!'

returned_string = return_example()
print(returned_string)
Luke
  • 744
  • 2
  • 7
  • 23
0

You have to define a function:

def my_function(...):
    for resultparameter in urine_dict ['patientresultslist']:
    #start by assigning each of the pieces of daa within parameter line
    resulparalist = resultparameter.split(';')
    reportstring = reportstring + vet.setwidth(resultparalist[0], 8) + lineterm + lineterm
    vert.setwidth(resultparalist[1[,10) + vet.setwidth(resultpatientlist)
    if config['Bargraph'].lower() == 'yes':
       reportstring = reporttring + vet.bargraph(resultparameterlist)

    return reportstring

And then, call it:

result = my_function(...)
print(result)
Néstor
  • 351
  • 1
  • 5
  • 20