Search code examples
pythonoperatorspython-3.6comparison-operators

Python - Is there a way to use a greater than operator that is not a comparison operator?


I am trying to make a program that only prints positions in a string that is greater than this position in the string, first i tried the > but it comes up with "Invalid syntax" and highlights it in red. I tried the comparison greater than but that does the same thing (Because i am not comparing) What i have tried:

sentence = ("Mark")
print (sentence[> 1])

What i want it to print: rk

If you have any solutions or alternatives to a greater than operator in Python please let me know and i will give it a go. :)


Solution

  • All you need to do is print (sentence[2:]) For future reference and research, it is called slice.