मुसीबत पाशन के लिए एक बिंदु में इनपुट सत्यापन कोड

0

सवाल

मैं सक्षम नहीं किया गया है करने के लिए बाहर आंकड़ा कैसे करने के लिए पाश वापस अपने कोड के लिए एक विशिष्ट बिंदु पर, मैं 2 पाश अंक और सबसे पहले एक काम करता है ठीक है, लेकिन मैं नहीं कर सकता प्राप्त करने के लिए एक दूसरे काम के रूप में मैं करने के लिए परिभाषित पूर्णांक चर "num_stores_int" लेकिन अगर मैं ऐसा है, तो "while" लूप काम नहीं करता है । मेरे कोड के लिए है, जहां उन बिंदुओं कर रहे हैं.

यहाँ अपने कोड:

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

ऊह मुझे नोटिस नहीं किया था और सोचा था कि आप सिर्फ पोस्ट मेरे एक ही कोड. वाह, मैं उम्मीद नहीं की थी कि काम करने के लिए. बहुत बहुत धन्यवाद है!!
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ý
..................................................................................................................