How to merge two codes?How to merge two dictionaries in a single expression?How do I check if a list is empty?How do I check whether a file exists without exceptions?How can I safely create a nested directory?How can I make a time delay in Python?How do I sort a dictionary by value?How to make a chain of function decorators?How to make a flat list out of list of listsHow do I concatenate two lists in Python?How do I list all files of a directory?

Trapping Rain Water

How to build suspense or so to establish and justify xenophobia of characters in the eyes of the reader?

How to tell your grandparent to not come to fetch you with their car?

What risks are there when you clear your cookies instead of logging off?

Which comes first? Multiple Imputation, Splitting into train/test, or Standardization/Normalization

Payment instructions allegedly from HomeAway look fishy to me

Should I compare a std::string to "string" or "string"s?

Genetic limitations to learn certain instruments

If you had a giant cutting disc 60 miles diameter and rotated it 1000 rps, would the edge be traveling faster than light?

How did they achieve the Gunslinger's shining eye effect in Westworld?

How do I write "Show, Don't Tell" as a person with Asperger Syndrome?

Find duplicated column value in CSV

What is the giant octopus in the torture chamber for?

What are the peak hours for public transportation in Paris?

Why doesn't Adrian Toomes give up Spider-Man's identity?

Scrum Master role: Reporting?

BGP multihome issue

Was the Tamarian language in "Darmok" inspired by Jack Vance's "The Asutra"?

What should the arbiter and what should have I done in this case?

Is the term 'open source' a trademark?

What's up with this leaf?

Why doesn’t a normal window produce an apparent rainbow?

How can I most clearly write a homebrew item that affects the ground below its radius after the initial explosion it creates?

Implement Homestuck's Catenative Doomsday Dice Cascader



How to merge two codes?


How to merge two dictionaries in a single expression?How do I check if a list is empty?How do I check whether a file exists without exceptions?How can I safely create a nested directory?How can I make a time delay in Python?How do I sort a dictionary by value?How to make a chain of function decorators?How to make a flat list out of list of listsHow do I concatenate two lists in Python?How do I list all files of a directory?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








-1















I am new at programming and was working on this project where I had written a code that reads an integer and displays, using asterisks, a filled and hollow square, placed next to each other but I am facing a but of an issue.



These are my codes and I know they are separate but I want to merge them to print the patterns side by side.



integer=int(input("Enter an integer:"))

for i in range(integer):

for j in range(integer+integer):

print("*",end="")

print()


print("*"*integer)

for i in range(integer-2):

print("*"+" "*(integer-2)+"*")

print("*"*integer)


expected output:



***** *****

***** * *

***** * *

***** * *

***** *****


Actual output:



***** 

*****

*****

*****

*****

*****

* *

* *

* *

*****









share|improve this question






















  • Instead of using print, save the strings in a list, combine, and only then print them out. Think of a print statement as the final output on screen, and once you print something, it should already be in the form you need it to be.

    – Paritosh Singh
    Mar 24 at 16:19

















-1















I am new at programming and was working on this project where I had written a code that reads an integer and displays, using asterisks, a filled and hollow square, placed next to each other but I am facing a but of an issue.



These are my codes and I know they are separate but I want to merge them to print the patterns side by side.



integer=int(input("Enter an integer:"))

for i in range(integer):

for j in range(integer+integer):

print("*",end="")

print()


print("*"*integer)

for i in range(integer-2):

print("*"+" "*(integer-2)+"*")

print("*"*integer)


expected output:



***** *****

***** * *

***** * *

***** * *

***** *****


Actual output:



***** 

*****

*****

*****

*****

*****

* *

* *

* *

*****









share|improve this question






















  • Instead of using print, save the strings in a list, combine, and only then print them out. Think of a print statement as the final output on screen, and once you print something, it should already be in the form you need it to be.

    – Paritosh Singh
    Mar 24 at 16:19













-1












-1








-1








I am new at programming and was working on this project where I had written a code that reads an integer and displays, using asterisks, a filled and hollow square, placed next to each other but I am facing a but of an issue.



These are my codes and I know they are separate but I want to merge them to print the patterns side by side.



integer=int(input("Enter an integer:"))

for i in range(integer):

for j in range(integer+integer):

print("*",end="")

print()


print("*"*integer)

for i in range(integer-2):

print("*"+" "*(integer-2)+"*")

print("*"*integer)


expected output:



***** *****

***** * *

***** * *

***** * *

***** *****


Actual output:



***** 

*****

*****

*****

*****

*****

* *

* *

* *

*****









share|improve this question














I am new at programming and was working on this project where I had written a code that reads an integer and displays, using asterisks, a filled and hollow square, placed next to each other but I am facing a but of an issue.



These are my codes and I know they are separate but I want to merge them to print the patterns side by side.



integer=int(input("Enter an integer:"))

for i in range(integer):

for j in range(integer+integer):

print("*",end="")

print()


print("*"*integer)

for i in range(integer-2):

print("*"+" "*(integer-2)+"*")

print("*"*integer)


expected output:



***** *****

***** * *

***** * *

***** * *

***** *****


Actual output:



***** 

*****

*****

*****

*****

*****

* *

* *

* *

*****






python python-3.x






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 24 at 16:15









Abdul MoizAbdul Moiz

31




31












  • Instead of using print, save the strings in a list, combine, and only then print them out. Think of a print statement as the final output on screen, and once you print something, it should already be in the form you need it to be.

    – Paritosh Singh
    Mar 24 at 16:19

















  • Instead of using print, save the strings in a list, combine, and only then print them out. Think of a print statement as the final output on screen, and once you print something, it should already be in the form you need it to be.

    – Paritosh Singh
    Mar 24 at 16:19
















Instead of using print, save the strings in a list, combine, and only then print them out. Think of a print statement as the final output on screen, and once you print something, it should already be in the form you need it to be.

– Paritosh Singh
Mar 24 at 16:19





Instead of using print, save the strings in a list, combine, and only then print them out. Think of a print statement as the final output on screen, and once you print something, it should already be in the form you need it to be.

– Paritosh Singh
Mar 24 at 16:19












2 Answers
2






active

oldest

votes


















0














Here you go.



integer=int(input("Enter an integer:"))


print("*"*integer + " " + "*"*integer)

for i in range(integer-2):
print("*"*integer + " " + "*" + " "*(integer-2) + "*")

print("*"*integer + " " + "*"*integer)


Output:



Enter an integer: 5

***** *****
***** * *
***** * *
***** * *
***** *****


Alternatively, here is one much easier to understand:



integer=int(input("Enter an integer:"))



full = "*"*integer
cap = full + " " + full
hollow = "*" + " "*(integer-2) + "*"

print(cap)
for i in range(integer-2):
print(full + " " + hollow)
print(cap)


Produces identical output






share|improve this answer
































    0














    This code works by separating the two unique lines:



    integer=int(input("Enter an integer:"))


    print("*"*integer + " " + "*"*integer)

    for i in range(integer-2):
    print("*"*integer + " " + "*" + " "*(integer-2) + "*")

    print("*"*integer + " " + "*"*integer)





    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55325836%2fhow-to-merge-two-codes%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      Here you go.



      integer=int(input("Enter an integer:"))


      print("*"*integer + " " + "*"*integer)

      for i in range(integer-2):
      print("*"*integer + " " + "*" + " "*(integer-2) + "*")

      print("*"*integer + " " + "*"*integer)


      Output:



      Enter an integer: 5

      ***** *****
      ***** * *
      ***** * *
      ***** * *
      ***** *****


      Alternatively, here is one much easier to understand:



      integer=int(input("Enter an integer:"))



      full = "*"*integer
      cap = full + " " + full
      hollow = "*" + " "*(integer-2) + "*"

      print(cap)
      for i in range(integer-2):
      print(full + " " + hollow)
      print(cap)


      Produces identical output






      share|improve this answer





























        0














        Here you go.



        integer=int(input("Enter an integer:"))


        print("*"*integer + " " + "*"*integer)

        for i in range(integer-2):
        print("*"*integer + " " + "*" + " "*(integer-2) + "*")

        print("*"*integer + " " + "*"*integer)


        Output:



        Enter an integer: 5

        ***** *****
        ***** * *
        ***** * *
        ***** * *
        ***** *****


        Alternatively, here is one much easier to understand:



        integer=int(input("Enter an integer:"))



        full = "*"*integer
        cap = full + " " + full
        hollow = "*" + " "*(integer-2) + "*"

        print(cap)
        for i in range(integer-2):
        print(full + " " + hollow)
        print(cap)


        Produces identical output






        share|improve this answer



























          0












          0








          0







          Here you go.



          integer=int(input("Enter an integer:"))


          print("*"*integer + " " + "*"*integer)

          for i in range(integer-2):
          print("*"*integer + " " + "*" + " "*(integer-2) + "*")

          print("*"*integer + " " + "*"*integer)


          Output:



          Enter an integer: 5

          ***** *****
          ***** * *
          ***** * *
          ***** * *
          ***** *****


          Alternatively, here is one much easier to understand:



          integer=int(input("Enter an integer:"))



          full = "*"*integer
          cap = full + " " + full
          hollow = "*" + " "*(integer-2) + "*"

          print(cap)
          for i in range(integer-2):
          print(full + " " + hollow)
          print(cap)


          Produces identical output






          share|improve this answer















          Here you go.



          integer=int(input("Enter an integer:"))


          print("*"*integer + " " + "*"*integer)

          for i in range(integer-2):
          print("*"*integer + " " + "*" + " "*(integer-2) + "*")

          print("*"*integer + " " + "*"*integer)


          Output:



          Enter an integer: 5

          ***** *****
          ***** * *
          ***** * *
          ***** * *
          ***** *****


          Alternatively, here is one much easier to understand:



          integer=int(input("Enter an integer:"))



          full = "*"*integer
          cap = full + " " + full
          hollow = "*" + " "*(integer-2) + "*"

          print(cap)
          for i in range(integer-2):
          print(full + " " + hollow)
          print(cap)


          Produces identical output







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 24 at 16:35

























          answered Mar 24 at 16:21









          PrinceOfCreationPrinceOfCreation

          19611




          19611























              0














              This code works by separating the two unique lines:



              integer=int(input("Enter an integer:"))


              print("*"*integer + " " + "*"*integer)

              for i in range(integer-2):
              print("*"*integer + " " + "*" + " "*(integer-2) + "*")

              print("*"*integer + " " + "*"*integer)





              share|improve this answer



























                0














                This code works by separating the two unique lines:



                integer=int(input("Enter an integer:"))


                print("*"*integer + " " + "*"*integer)

                for i in range(integer-2):
                print("*"*integer + " " + "*" + " "*(integer-2) + "*")

                print("*"*integer + " " + "*"*integer)





                share|improve this answer

























                  0












                  0








                  0







                  This code works by separating the two unique lines:



                  integer=int(input("Enter an integer:"))


                  print("*"*integer + " " + "*"*integer)

                  for i in range(integer-2):
                  print("*"*integer + " " + "*" + " "*(integer-2) + "*")

                  print("*"*integer + " " + "*"*integer)





                  share|improve this answer













                  This code works by separating the two unique lines:



                  integer=int(input("Enter an integer:"))


                  print("*"*integer + " " + "*"*integer)

                  for i in range(integer-2):
                  print("*"*integer + " " + "*" + " "*(integer-2) + "*")

                  print("*"*integer + " " + "*"*integer)






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 24 at 16:21









                  Alec AlameddineAlec Alameddine

                  1




                  1



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55325836%2fhow-to-merge-two-codes%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                      SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                      은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현