Whats wrong with my first python codes?
H? 伙计们我刚刚开始学习python编程,这是我的第一个代码。为什么不退出程序时呢? 输入"q"
print("bu program s?cakl ?? a g?re suyun durumunu g?sterir")
而真:
s =输入("lütfens?cakl ??? giriniz.??kmak i?n q ya bas")
如果s =="q":
打印("-6 K -1升?侑")
1 | break |
尝试:
1 | s_int=int(s) |
除了ValueError:
1 2 | print("Lütfen sadece say? giriniz") raise |
如果s_int <0:
1 | print("Durum Buzdur") |
elif s_int> = 100:
1 | print("Durum Buhar") |
其他:
1 | print("Durum su") |
1 | s=int(input("lütfen s?cakl??? giriniz")) |
如果您立即将输入转换为
如果您的程序应该立即跳转到
要解决此问题,您可以先将原始输入与
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | s=input("lütfen s?cakl??? giriniz") if s=="q": print("??k?l?yor") break try: s_int = int(s) except ValueError: print("Please enter a valid integer or 'q'") raise if s_int<0: print("Durum Buzdur") elif s_int>=100: print("Durum Buhar") else: print("Durum su") |