Showing Side Effect Error in some Python Complilers for matrixflip function

戏子无情 提交于 2020-01-06 08:36:12

问题


I have written a code and i have to verify it on the online compiler for this purpose. But that compiler is showing following error.Attaching the image

Also my code is as follows:

def matrixflip(m,d):
    n=m
    x=len(n[0][0:])
    if(d=="h"):
        for i in range(len(n)):
            for j in range(x-1):
                temp=n[i][j]
                n[i][j]=n[i][j+1]
                n[i][j+1]=temp
        print(n)

    elif(d=="v"):
        temp=[]
        for i in range(len(n)-1):
            temp=n[i][0:]
            n[i][0:]=n[i+1][0:]
            n[i+1][0:]=temp
        print(n)

    else:
        print(m)

myl=[[1,2],[3,4]]
matrixflip(myl,"h")

Please answer what should i do.

来源:https://stackoverflow.com/questions/54774723/showing-side-effect-error-in-some-python-complilers-for-matrixflip-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!