Search code examples
pythonmit-scratch

What function could be workaround of this Scratch block in Python?


I want to know, what is a workaround/replacement for this Scratch block:

(letter (...) of (...))

In Python. I know that in JavaScript, the answer is:

"..."[... - 1]

Solution

  • The code is the same as in JavaScript, like:

    var alphabet = "ABCDEFGHIJKLNOPQRSTUVWXYZ"
    var letter1 = alphabet[0]
    var letter2 = alphabet[1]
    var letter3 = alphabet[2]
    var letter123 = letter1 + letter2 + letter3
    
    alert("The first three letters of the alphabet are: " + letter123)
    

    I was very d**b