PTA-第三章-7-17 输出10个不重复的英文字母 (50分)

随机输入一个字符串,把最左边的10个不重复的英文字母(不区分大小写)挑选出来。 如没有10个英文字母,显示信息“not found”

输入格式:
在一行中输入字符串

输出格式:
在一行中输出最左边的10个不重复的英文字母或显示信息“not found"

输入样例1:
在这里给出一组输入。例如:

poemp134

输出样例1:
在这里给出相应的输出。例如:

not found

输入样例2
在这里给出一组输入。例如:

This is a test example

输出样例2:
在这里给出相应的输出。例如:

Thisaexmpl

代码

s=input()
count=0
data=[]
for i in range(len(s)):
    if  s[i].isalpha() and ("a"<=s[i]<="z" or "A"<=s[i]<="Z"):
        if s[i].upper() not in data and s[i].lower() not in data:
            count+=1
            data.append(s[i])
            if count == 10 :
                break
if count ==10:
    for i in data:
        print(i,end="")
else:
    print("not found")
    
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
根据引用,C语言代码pta7-1可以实现输入一个1到7的数字,输出对应的星期名的缩写。以下是一个实现该功能的C语言代码示例: ``` #include <stdio.h> int main() { int n; char* s[] = {"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"}; printf("请输入一个数字(1-7):"); scanf("%d", &n); printf("%s\n", s[n-1]); return 0; } ``` 这段代码会提示用户输入一个1到7的数字,然后根据输入的数字输出对应的星期名的缩写。例如,输入1会输出"Mon",输入2会输出"Tue",以此类推。注意,由于数组的索引是从0开始的,所以我们需要将输入的数字减去1来得到正确的索引值。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [PTA 第五章算法题汇总](https://blog.csdn.net/billlee7942/article/details/106250002)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [PTA-MOOC《Python程序设计浙江大学》拼题题目集第五章编程题题目及代码答案](https://blog.csdn.net/weixin_45115928/article/details/104516791)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值