+ 1
Python Control Flow Task Question
Hi, Iâve been stuck at the task âGoing once, going twice, sold!â Task for a while now and I canât seem to find whatâs exactly wrong with my code. My code looks like this: maxBid = int(input()) while(True): bid = int(input)) if bid > maxBid: break print(âSold:â , bid) Thanks in advance!!
11 RĂ©ponses
+ 4
Now your print statement is inside loop. But should be after loop like in your original previous code.
+ 7
Eleni D ,
just some words about the code formatting.
> styleguide for python code is described in pep-0008.
> indentation should be 4 spaces per indentation level. this has a much better readability than using only one space.
this the link to the style guide:
https://peps.python.org/pep-0008/#indentation
+ 3
What's the task?
Normally, with these tasks, you really have to pay attention to how the output should look like. Do you have the right amount of space etc?
+ 3
You are missing the () for the input() function in loop.
And you are using the wrong quotes for string. Use double quotes "Sold:"
+ 3
Ok, so there are possibly a few things wrong.
1st: bid = int(input()) #you're missing a (
2nd: if bid >= maxBid: #the maximum bid is met if the bid is the same amount or greater
3rd: print("Sold:", bid) #I don't know if you're using quotation marks or 2x backticks
+ 3
You are a genius! Crazy how much the little details matter! Thanks to both you
+ 2
Task:
You are writing a program for an auction where the maximum bid is set. The number of bids is variable.
Task
Complete the program to take all bids from auction participants until the maximum bid is met.
The program should output a message with the winning bid.
Input Example
1600
800
1300
1700
Output Example
Sold: 1700
Explanation
The first input represents the set maximum bid, followed by the bids offered by all participants. The last participant offered a bid of 1700, which is above the maximum set bid of 1600, and therefore wins the auction. Therefore, that bid is displayed.
+ 1
Updated the code but it's still not working
maxBid = int(input())
while(True):
bid = int(input())
if bid >= maxBid:
break
print("Sold", bid)
+ 1
print(f"Sold: {bid}")
Try this if it works good its ok
But if not ask for chatgpt
And try to edit this also
if bid == 'maxBid':
+ 1
Mohammad Mondgar please don't try to hijack another person's thread.
If you have a question, search the forum first, do some research online and then, if you still don't have your answer, ask and provide some code which needs help.
Furthermore, malicious hacking is not a very moral or ethical thing to do. Couldn't you put your energy into something more beneficial for the rest of your world?
0
Hi! I want to know all hackers code but send for me pleaseđđ