logo

🧪 字符串操作

⏱️ 20-25 min📊 Beginner
main.py
Costs 1 credit
加载编辑器中...
输出 Output执行成功
# 运行代码后,输出将显示在这里
# 按 Ctrl+Enter 快速运行
Terminal (Simulated)Install commands are simulated only, no real network requests
$

Step 1: 字符串拼接

字符串拼接是“把分散信息组装成可读句子”的基础能力。

底层逻辑:
当两边都是字符串时,+ 触发的是“连接操作”,不是数学加法。
程序会创建一个新字符串,把左边和右边按顺序拼起来。
这就像把“姓”和“名”贴在同一张名牌上。中间如果不手动加空格,名字会粘在一起。

你的任务

  1. 创建 first_name = "John"
  2. 创建 last_name = "Doe"
  3. 拼接并输出 "John Doe"

Self-Check List

  • 使用 + 拼接字符串

Transfer Template

print(first_name + " " + last_name)
After completing this step, you should be able to independently explain and reproduce this concept, then apply it to similar problems.

验证清单 (0/0)