-12

i have this c++ code.

        int range = 0;

        cin>>range;

        int input[range] = {0};

    //      inserting in array
        for(int i=0; i<range;i++)
        {
            cin >>input[i];
        }

    //  Printing out from array
        for(int i=0; i<range;i++)
        {
            cout<<input[i];
        }

i am wondering how to write this piece of code in python which does the same thing. i am a beginner in python so i haven't tried much things out yet.

Craftx398
  • 341
  • 1
  • 2
  • 13

1 Answers1

0
count = int(input())
values = [int(input()) for _ in range(count)]
for v in values:  # alternatively, print(" ".join(str(v) for v in values))
  print(v)
Amber
  • 507,862
  • 82
  • 626
  • 550
  • isnt there anything much simpler for a beginner to understand or if you could just comment your codes. – Craftx398 Apr 23 '17 at 21:16
  • 1
    Whilst this code snippet is welcome, and may provide some help, it would be [greatly improved if it included an explanation](//meta.stackexchange.com/q/114762) of *how* it addresses the question. Without that, your answer has much less educational value - remember that you are answering the question for readers in the future, not just the person asking now! Please [edit] your answer to add explanation, and give an indication of what limitations and assumptions apply. – Toby Speight Apr 24 '17 at 11:37
  • 1
    Please add more information and context. What does this code do and how does this answer the user's question? If you're going to make a code-only answer, the code needs to at least be well commented. – Al Sweigart Apr 24 '17 at 18:20
  • @AlSweigart Dude, this is an answer on a marked-as-dupe question. There are better ways for you to spend your time. – Amber Apr 29 '17 at 20:42