String length without len function

前端 未结 17 1320
逝去的感伤
逝去的感伤 2020-12-10 21:29

Can anyone tell me how can I get the length of a string without using the len() function or any string methods. Please anyone tell me as I\'m tapping my head ma

17条回答
  •  醉话见心
    2020-12-10 22:09

    def length(object):#Define the length calculation function
    
        count = 0  #initializing the length to be equal to zero
        object = input() #enter the argument 
    
        for i in object:
            count=count+1
    
        print("Length of the string is"+str(count))
    
    length(object)
    

提交回复
热议问题