📜  没有 len 函数的列表长度 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:12.005000             🧑  作者: Mango

代码示例1
def string_length(my_string):
    """returns the length of a string
    """
    counter = 0
    for char in my_string:
        counter += 1
    return counter

# taking user input
string_input = input("enter string :")
length = string_length(string_input)

print("length is ", length)