1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Python basics - square brackets

Discussão em 'Python' iniciado por Stack, Julho 27, 2025.

  1. Stack

    Stack Membro Participativo

    I am at the beginning on my path to code. I've started learning code on my own. I am looking for help with basic python program. My goal is to create basic program in which:

    • there is a piece of text 10 characters long
    • program asks to choose number between 0-9
    • program returns the letter which is equal to the number chosen by person using the program.

    To simplify it:

    • Text: Sample text: Please choose number 0-9
    • Answer: 5
    • Return: e

    Here is piece of my code:

    text = "Let's check"
    text1 = text
    print(text)
    digit = input('Choose digit between 0-9')
    print(int(digit))
    print(text1[digit:6])


    My problem is to put variable into the square bracket. Unfortunately it does not work. I know the problem begins in two last lines of the code.

    I am not looking for ready solution. I would like to kindly ask you to show me way how to solve it. Thank you very much!

    Continue reading...

Compartilhe esta Página