0

Can someone please explain what "r[ i ]" and " r[~i] " mean in this solution?

# Python3 program to print diagonals in 2D list 

def printDiagnol(lst): 
    # To print Primary Diagnol 
    print('Diagnol 1 - ', end ="") 
    print([r[i] for i, r in enumerate(lst)]) # what is r[i]?
  
    # To print Secondary Diagnol 
    print('Diagnol 2 - ', end ="") 
    print([r[~i] for i, r in enumerate(lst)])# what is r[~i]? 

  
# Driver code 
lst = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] 
printDiagnol(lst) 
2
  • 1
    This question isn't about enumerate. Commented Oct 30, 2020 at 2:57
  • basically, I just want to know what r[I] and r[~I] means Commented Oct 30, 2020 at 3:01

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.