"Length of () (block)" redirects here. For the List block, see Length of () (List block).
 字串長度 () `字串長度\( (詢問的答案) \)` 類別 運算類積木 形狀 橢圓形積木 加入於 1.4

The Length of () 積木 is an 運算類積木 and a 橢圓形積木. The block reports how many characters the given 字串 contains. Note: Spaces count as characters in strings.

## 用法示例

In certain 專案, different events can happen based on the length of a value; this block is used to help.

Some common uses for the Length of () block:

• Checking the length of a name
```詢問 [What's your name?] 並等待

```
• Checking how many digits there are in a player's score
```重複無限次
說出 (字串長度\( (score1) \))
end
```
• Chatbots, where different messages can occur depending on the length of the message that was inputted
```如果 <(字串長度\( (詢問的答案) \)) < (10)> 那麼
說出 [Hi!]

說出 [Bye!]
end
```

## 應用

Main article: List of Block Workarounds

This block can be replicated with the following code:

```變數 [length v] 設為 

變數 [length v] 改變 (1)
end
```

It can be flawed because it can be long and slow. This is also a problem:

```變數 [repcount v] 設為 (0)

新增項目 (字串中第 ((repcount) + (1)) 字\( (string) \)) \( [results v] \)
變數 [repcount v] 改變 (1)
end

```

It takes up lots of memory and can be slow. However, both values can be saved for later.

## 參見

— the version for 清單s