-3

I want to use returned values separately. But the output I get: Output Goten vs Output I want: Output Wanted

My Code:

def Summer_69(a):
        if 6 in a and 9 in a:
            b=a.index(6)
            c=a.index(9)
            if c>b:
                for i in range(c-b):
                    for i in range(b,len(a)-1):
                        a[i]=a[i+1]

                    a.pop()
                a.remove(9)
        a.remove(None)
        sum=0
        for i in a:
            sum = sum+i
        return a,sum
    a = []
    b = int(input("Enter size of the list : "))
    for i in  range(b):
        val=int(input("Enter values : "))
        a.append(val)
    print("Original list : ",a)
    a.append(None)
    x=Summer_69(a)
    print("Summur 69 List : ",x)
    print('Sum : ',x)

Please Help!

  • Welcome to Stack Overflow. Please read [ask] and the [formatting help](https://stackoverflow.com/help/formatting). Make sure your code appears with its exact indentation, and show expected and desired textual output [as text, not an image](https://meta.stackoverflow.com/questions/285551). We [will not transcribe](https://meta.stackoverflow.com/questions/415040) images for you. That said, of course `print(x)` twice in a row will show the same value, no matter what `x` is. – Karl Knechtel Aug 31 '22 at 08:15
  • your code has wrong indentation and won't run –  Aug 31 '22 at 08:15

1 Answers1

1

replace x=Summer_69(a) this line by following this way, you can unload the return value in different values.

summer_69_list, total_sum = Summer_69(a)

print(summer_68_list) # [1,3,5] print(total_sum) # 9

shivankgtm
  • 1,207
  • 1
  • 9
  • 20