安全问答

安全问答是一个知识全球问答,包含丰富的问答知识

首页 常规 游戏 娱乐 科技 程序员

list=inputsplitlistsortnum=lenlistj=int1for i in list ifj!=num printinti+- else printintij+=1代码问题出在哪里

  • 日期: 2028-10-11
  • 标签: 教育

代码问题出在j+=1应该放在if-else语句的外面,否则j的值无法正确更新。正确的代码如下:

list=input().split()
list.sort()
num=len(list)
j=int(1)
for i in list:
    if(j!=num):
        print(int(i)+"->")
    else:
        print(int(i))
    j+=1
list=inputsplitlistsortnum=lenlistj=int1for i in list ifj!=num	 printinti+- else	 printintij+=1代码问题出在哪里

原文地址: https://www.cveoy.top/t/topic/iiVW 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录

  • 上一篇: android开发:我想做一个展示地图然后选择一个地点拿到这个地点的经纬度的功能不想用Google Maps API因为它收费有其他地图api能用吗?有示例代码或git地址吗
  • 下一篇: 翻译Explained variables Many current studies employ pass rate and standardization in prescription lists as criteria for assessing the quality of prescriptions In our study the percentage of the number o

© 2019 • 2025 - 安全问答 站长邮箱:wxgpt@qq.com    ICP备案/许可证号:豫ICP备2024104334号-2