Well, This is what i got
n = int(input("enter number of o: "))
for i in range(n):
print("O", end = '')
for j in range(n* 2):
print("O", end = '')
print()
Okay! Good. Now, presumably this isn't working yet, or you wouldn't be
asking. So we just need the other crucial part of the puzzle: What is
it doing wrong? That might be an exception (copy and paste it all,
including the full traceback), or it might be producing the wrong
output, or maybe it produces the right output on everything except
some specific input.
I'll level with you here. We do not want to do your homework for you,
and we do not want anyone else to do your homework. When you're asked
to write code like this, it's not because the teacher/tutor wants the
code written - it's because you need to learn what you're doing.
Having someone else hand you perfectly working code defeats that
purpose, and it will tend to produce a sort of faux comprehension that
results in you getting a certificate and a job, while being still
quite incompetent as a programmer. Now, you may protest that it's not
as bad as that (and you'd probably be right - you have produced some
partially-working code there), but that's the extreme, and going even
part-way down that path is a Bad Thing. We, as programmers, would hate
to be coworkers to someone who glided through some course by getting
someone else to do the work; we do not want to have to try to work
with that sort of person.
(Digression: I have, and quite a few of us here probably have, worked
with exactly such a person. In my case, eventually even the boss/owner
figured out that he was a rubbish programmer; when we eventually dug
into his code thoroughly, we threw out the whole lot and literally
started over with a blank file. But before that, we found gems like
this PHP code - by the way, it *is* possible to write good PHP code,
even though the language is itself pretty appalling, but this... isn't
proof of that.
$step = 1;
do
{
switch ($step) {
case 1:
.... code code code ....
break;
case 2:
.... code code code ....
break;
default:
... raise an error ....
}
} while (++$step<2);
This code was supposed to verify certain requirements on an incoming
HTTP request. What you may not notice - and I didn't notice when I saw
this and decided to simplify the code - is that this is NOT the
for-switch paradigm, it's something even worse: a for-switch with an
off-by-one, so the only code actually executed is the "case 1" block.
And since we had properly working code in our client, none of the
errors that the "case 2" block was supposed to catch ever actually got
triggered, so we didn't see a problem... until I cleaned up the code,
and discovered that "case 2" had bugs in it. This is what happens when
you have incompetent people writing code. This is why we are strongly
disinclined to give you the answers. End digression.)
However, while we won't just give you the answers, we *will* gladly
help you to understand what's going on. So if you post code and output
(maybe an error) and ask a specific question, preferably one that
shows some level of comprehension, we will cheerfully put in quite a
bit of time to help you understand the error message, or learn how to
decipher Python tracebacks, or whatever. Helping you to understand
things makes you a better programmer, and by extension improves the
world's total programming skill; giving you the answers makes you no
better and possibly worse (by encouraging laziness), and so we don't
want to do it.
So, there you have it. Don't be a bad programmer.
You'll find more
handy tips here - it's an invaluable resource:
http://www.catb.org/~esr/faqs/smart-questions.html
ChrisA