当前位置:网站首页>The reason why "typeerror: 'STR' object does not support item assignment" appears
The reason why "typeerror: 'STR' object does not support item assignment" appears
2022-07-21 19:23:00 【If you don't study today, you will become a cured chicken tomor】
1. translate
‘TypeError: ‘str’ object does not support item assignment’:
Type error : ‘str’ Object does not support item assignment
** You can traverse the string , But every value in the string cannot be changed , Unless you assign it again
str = input()
str_length = len(str)
# Numbers 、 Strings and tuples are immutable objects
for i in range(0,str_length):
str[i] = int(str[i])
print(str)
practice :
subject :
describe
Niuniu and niumei play password games together , Niuniu, as the sender, will send a 4 Give the whole number of digits to Niu Mei , Niu Mei will crack the password after receiving it .
The solution is as follows : Add... To every number 3 Divided by 9 Replace this digit with the remainder of , And then I will 1 Position and number 3 Bit digital switching , The first 2 Position and number 4 Bit digital switching .
Please output the password that Niu Mei cracked .
Input description :
Enter a four digit integer .
Output description :
Output the cracked password , In the form of four digits .
Example 1
Input :
1234
Copy
Output :
6745
Copy
remarks :
Input will not have a prefix 0, But the output should be kept in front 0
Answer key :
str = input()
count = []
for i in str:
count.append(int(i))
for i in range(0,4):
count[i] = count[i] + 3
count[i] = count[i] % 9
print(count[2],end='')
print(count[3],end='')
print(count[0],end='')
print(count[1],end='')
边栏推荐
- Teach you how to install MySQL database by hand
- 分布式.常用架构和服务拆分
- Clickhouse in-depth disclosure
- SAP IDOC教程:定义,结构,类型,格式和表格-019
- 05 正则表达式语法
- Top 10 NFTs at present
- How to solve the problem of unable to establish SSL connection in WGet command
- Distributed High concurrency & high availability
- 分布式.高可用 高可扩展 指标
- Time series data: prediction
猜你喜欢
【性能优化】MySQL常用慢查询分析工具
Ardunio development - use of soil sensors
滲透測試-文件包含漏洞以及php偽協議的應用
[information retrieval] implementation of information retrieval system
Use the mogdb operator to deploy the mogdb cluster (mogdb stack) on kubernetes
不想醒来因为好吃
hcip第二天实验
[qt primer] Application of window classes
Sorting out of high-frequency interview questions, answers and knowledge context of Android, a major Internet company in 2022
Pytoch environment construction
随机推荐
NFS service configuration
【性能优化】MySQL常用慢查询分析工具
Web APIs DOM page special effects element size and position
SAP smartforms 打印失败 消息类型:SSFCOMPOSER 消息号:601 (货币和数字字段设置参考及格式)
分布式.数据库架构
Configuration du Service FTP
Mapbox GL development tutorial (13): loading 3D surface layers (white mold)
Metahuman face shader summary
Distributed High availability and high scalability index
Distributed High concurrency & high availability
LBA converted to CHS formula
China phosphorus pentachloride Market Research and investment forecast report (2022 Edition)
L1-008 求整数段和
Software testing interview questions: black box testing and white box testing are two basic methods of software testing. Please explain their advantages and disadvantages respectively!
分布式.高性能
Software testing interview question: what is the task of testers in the process of software development?
How easyexcel exports files in a project
分布式.容量评估
分布式.高并发&高可用
What is gamefi?