题解 | #格式化输出(一)#
https://www.nowcoder.com/practice/fe82dc48f4f04b2397a85fb1bdbe34a2
格式化输出
描述
牛牛、牛妹和牛可乐正在Nowcoder学习Python语言,现在给定他们三个当中的某一个名字name,
假设输入的name为Niuniu,则输出 I am Niuniu and I am studying Python in Nowcoder!
请按以上句式输出相应的英文句子。
输入描述:
一行一个字符串表示名字。
输出描述:
假设输入的name为Niuniu,则输出I am Niuniu and I am studying Python in Nowcoder!
请按以上句式输出相应的英文句子。
示例1
输入:
Niuniu复制
输出:
I am Niuniu and I am studying Python in Nowcoder!
names={"Niuniu":["I am Niuniu and I am studying Python in Nowcoder!"],
"Niumei":["I am Niuniu and I am studying Python in Nowcoder!"],"Niuke":["I am Niuke and I am studying Python in Nowcoder!"]
}
name=input()
for i in names:#遍历字典
if name==i:#遍历字典获取key,通过key和输入的值判断
print(names[name])
题解:2
name = input()
print('I am {} and I am studying Python in Nowcoder!'.format(name))
print(f'I am {name} and I am studying Python in Nowcoder!')