I came across this code , that matches the \* wildcard against a string. \* can be considered as 0 or more characters. 

```
def samePattern(main,pattern):
    if pattern=="*" or main==pattern:
        return True
    if main=="":
        return False
    if main[0:1]==pattern[0:1]:
        return samePattern(main[1:],pattern[1:])

    if pattern[0:1]=="*":
        return samePattern(main[1:],pattern) or samePattern(main,pattern[1:])

    return False

```

While I think I understood the base cases, I am not understanding how the line

```
if pattern[0:1]=="*":
        return samePattern(main[1:],pattern) or samePattern(main,pattern[1:])

```

is working. 

Could anybody explain how it is working ?