문제 반복 시점에서 입증 코드

0

질문

나는 할 수 없었던 방법을 알아낼 내 루프 코드의 특정 시점으로,저는 2 개의 루프가 포인트와 첫 번째는 작동하지 않습 번째 작품으로 나를 정의하는 변수"num_stores_int"그러나 내가 할 경우,그는 동안""루프가 작동하지 않습니다. 내 코드는 해당 포인트니다.

여기 나의 코드:

num_stores = ("")
num_stores_int = int(num_stores)
while num_stores.isnumeric() == False:
    while num_stores_int > 10: #This is where I want it to loop to 
        num_stores = input ("\n To start, please enter the amount of stores you own: ")
        if num_stores.isnumeric() == True:
            num_stores_int = int(num_stores)
            if num_stores_int > 10: #this is where I want the "while" loop to validate the integer being less than 10
                print (" Sorry, this sales tracker can track a maximum of 10 stores.\n Here, try that again, I'll reboot it for you.\n")
                print (" -----------------------REBOOTING------------------------")
            if num_stores_int >= 5:
                print ("\n Hmm, interesting, you'd think someone with that many \n stores would be able to afford a better sales tracker.")
                print (" Well, I guess you're stuck with me! MUHAHAHAHA!!......\n\n Anyway,")
                print (f" clearly big business person, you own {num_stores_int} stores.\n I'm gonna need you to tell me where each one is")
            else:
                num_stores_int = int(num_stores)
                print (f" Alright... so, random business person, you have {num_stores_int} stores.\n Now, I'm going to need you to tell me where each one is")
        else:
            print ("\n Hey, uhh, you're going to have to write a number for the\n amount of stores you've got, letters and decimals don't \n really work. Here, try again, I'll reboot it for you.\n")
            print (" -----------------------REBOOTING------------------------")
integer loops python validation
2021-11-23 02:30:07
2
0

그것은 최고 명확하고 무엇을 찾고 있습니다,그러나 내가 믿고 있는 것 외부 while 반복을 의미하는지 묻는 사용자에게 입력 할 때 그들은 입력하지 않는 무언가 숫자?

나는 것만 포장 while 루프 주위에 코드를 요구하는 사용자 입력을 위해 다음과 같다:

num_stores = ("")
num_stores_int = 0
while num_stores_int < 10: #This is where I want it to loop to
    num_stores = input ("\n To start, please enter the amount of stores you own:")
    while num_stores.isnumeric() == False:
        print ("\n Hey, uhh, you're going to have to write a number for the\n amount of stores you've got, letters and decimals don't \n really work. Here, try again, I'll reboot it for you.\n")
        print (" -----------------------REBOOTING------------------------")
        num_stores = input ("\n To start, please enter the amount of stores you own:")

    num_stores_int = int(num_stores)
    if num_stores_int > 10: #this is where I want the "while" loop to validate the integer being less than 10
        print (" Sorry, this sales tracker can track a maximum of 10 stores.\n Here, try that again, I'll reboot it for you.\n")
        print (" -----------------------REBOOTING------------------------")
    elif num_stores_int >= 5:
        print ("\n Hmm, interesting, you'd think someone with that many \n stores would be able to afford a better sales tracker.")
        print (" Well, I guess you're stuck with me! MUHAHAHAHA!!......\n\n Anyway,")
        print (f" clearly big business person, you own {num_stores_int} stores.\n I'm gonna need you to tell me where each one is")
    else:
        print (f" Alright... so, random business person, you have {num_stores_int} stores.\n Now, I'm going to need you to tell me where each one is")
2021-11-23 02:51:38

그래,외부 하는 동안 반복은 나를 위해 일하고 있지만 안나지 않기 때문에 내가 있을 정의하는 변수 num_stores_int 는지 확인하기 위해서 그것의 수에 따라 10 그러나 내가 할 경우,그것을 이미 정의된 값이 아닌 하나의 사용자가 입력 및 작동하지 않는
Weaver Ant

@Clandestinity 조금 더 구체적으로 작동하지 않는 것에 대해 코드와 게시
Erik McKelvey

우 촬영하지 않았다 변화와 생각을 그냥 재 내 같은 코드입니다. Wow,기대하지 않았다. 감사합니다 그래서 많은 사람!!
Weaver Ant

@Clandestinity 나는 당신이 새로운다. 을 느낄 경우 응답 문제를 해결하십시오크로 받아들여'클릭하여 그린에 체크 표시가 나타납니다. 이것을 유지하는 데에 초점을 노래는 여전히 있지 않는 답변이 있습니다.
Erik McKelvey

아싸는 명백한 xD 감사,당신이 뭔가를 찾고 있었으로 표시하는 정답입니다. 죄송하지만,늦은 내 두뇌는 완전히 튀 XD
Weaver Ant

@Clandestinity 모든 좋은,당신을 감사하십시오!
Erik McKelvey

요 죄송을 취소하는 것은 내가 단지 그것을 실현하지 않았다 문제를 해결합니다. 그것은 나쁜에,나는 그것을 설명한 제대로 하지만 난 그냥 무언가를 시도하고 일했다. 도와 주셔서 감사합니다.
Weaver Ant

최고의 응답

0

나의,나쁜 나가야 제대로 설명이 무엇을 잘못했지만 나는 그냥 무언가를 시도하고 일했다.

def restart():
    num_stores = ("")
    while num_stores.isnumeric() == False: 
        num_stores = input ("\n To start, please enter the amount of stores you own: ")
        if num_stores.isnumeric() == True:
            num_stores_int = int(num_stores)
            if num_stores_int > 10:
                print ("\n Sorry, this sales tracker can track a maximum of 10 stores.\n Here, try that again, I'll reboot it for you.\n")
                print (" -----------------------REBOOTING------------------------")
                restart()
            elif num_stores_int >= 5:
                print ("\n Hmm, interesting, you'd think someone with that many \n stores would be able to afford a better sales tracker.")
                print (" Well, I guess you're stuck with me! MUHAHAHAHA!!......\n\n Anyway,")
                print (f" clearly big business person, you own {num_stores_int} stores. I'm gonna\n need you to tell me where each one is")
            else:
                num_stores_int = int(num_stores)
                print (f" Alright... so, random business person, you have {num_stores_int} stores.\n Now, I'm going to need you to tell me where each one is")
        else:
            print ("\n Hey, uhh, you're going to have to write a number for the\n amount of stores you've got, letters and decimals don't \n really work. Here, try again, I'll reboot it for you.\n")
            print (" -----------------------REBOOTING------------------------")
restart()
2021-11-23 02:41:49

다른 언어로

이 페이지는 다른 언어로되어 있습니다

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................