Hello There i am working on python project for my python course project so i need to get number from users so enter image description here

here is my test codes but the output is like that enter image description here

i want to store my imput datas like this one [2] not like this ['2'] what can i do for solve this. Thanks for help

  • 盛水冬
    盛水冬 回复

    by declaring new variable as input and without declaring what type it is, python will adress the variable as string. you will need to convert your variable:

    yinp= int(input("enter your number")

  • 小情歌
    小情歌 回复


    yinp = int(input('enter your number'))

    Explanation: By default python will take the inputs as string, you need to convert it to required type. In this case you need to convert into integer, int() is helpful for you.