Python Vending Machine | Vending machine Python

Python Vending Machine. Hi all, I'm having trouble with the Vending Machine problem. I am able to pass all the tests outside of #4.-1Hiall,I’mhavingtroublewiththeVendingMachineproblem.Iamabletopassallthetestsoutsideof#4.Ihavetriedtestingitwithinputs0-30anditiscomingbackwithwhatisshould.Unless#4isanegativenumberinwhichcaseitgivesthelistinreverse(-1=avocado,-2=peach,etc).Thanksforlookingoverthis.fruits=[“apple”,“cherry”,“banana”,“kiwi”,“lemon”,pear”,“peach”,“avocado”]num=int(input())ifnum==0ornum<=7:print(fruits[num])else:print(“Wrongnumber”)pythonlisthelpmachinevending6/8/20214:08:49PMEliseDavis2AnswersNewAnswerSortby:VotesDate+3Yourif-conditionreads"ifnumisequalto0ORnumissmallerthan/equalto7"Ifnum=-1,thentheconditionwouldevaluatetoTrue,asnum==0ornum<=7=>0==-1or0<=7=>FalseorTrue=>TrueWhichmeansthestatementintheif-blockwillbeexecutedandhence,yourif-conditionisprettymuchuseless.Hint:theconditionshouldbe"ifnumis*greaterthan/equalto*0andnumissmallerthan/equalto7"XXX0Youmayalsodo:ifnum1<=num<=num2:So2comparesinoneif.PaulHotTodayCanIbuildAWebsiteusingHtmlonmobile?TricktoachieveLevel17Cananyonetellmewhat'swrongwiththiscodeplease?Reversestring-problemsolvingWhythisicondonotchangeAnybodyfixthecode?I'msobadatmathchallengesTryingtomakeincountdownfrom3210Mymind'[email protected],Suite1455SanFrancisco,CA94111EmailUsHomeCoursesBlogContactTermsofUsePrivacyPolicyFAQ©2021Sololearn,Inc.SendusamessageName:Email:Message:


常見投資理財問答


延伸文章資訊