Python double quotation syntax issue












0















This is my code:



for i in range(0, row_count):
if counter<row_count-1:
lines.append(""" var flightPlanCoordinates = [
{lat:""" + latitude[i] + """, lng: """ + longitude[i] + """}
{lat:""" + latitude[i + 1] + """, lng: """ + longitude[i + 1] + """}
];
""")
lines.append("""var flightPath"""+i+""" = new google.maps.Polyline({
path: flightPlanCoordinates,
geodesic: true,
strokeColor: '#FF0000',
strokeOpacity: 1.0,
strokeWeight: 5
});""")
counter += 1


I'm trying to figure out why this isn't compiling(I'm getting a syntax error). This is a string that will be part of the code to an html page. I want to create i flight path variables, each named flightpathi. So flightpath0, flightpath1 and so forth. When using """+i+""" or any other variable inside triple quotations on other lines, this works. I know this is probably something pretty simple that I'm overlooking, but I'm stuck and I'd appreciate any help!










share|improve this question





























    0















    This is my code:



    for i in range(0, row_count):
    if counter<row_count-1:
    lines.append(""" var flightPlanCoordinates = [
    {lat:""" + latitude[i] + """, lng: """ + longitude[i] + """}
    {lat:""" + latitude[i + 1] + """, lng: """ + longitude[i + 1] + """}
    ];
    """)
    lines.append("""var flightPath"""+i+""" = new google.maps.Polyline({
    path: flightPlanCoordinates,
    geodesic: true,
    strokeColor: '#FF0000',
    strokeOpacity: 1.0,
    strokeWeight: 5
    });""")
    counter += 1


    I'm trying to figure out why this isn't compiling(I'm getting a syntax error). This is a string that will be part of the code to an html page. I want to create i flight path variables, each named flightpathi. So flightpath0, flightpath1 and so forth. When using """+i+""" or any other variable inside triple quotations on other lines, this works. I know this is probably something pretty simple that I'm overlooking, but I'm stuck and I'd appreciate any help!










    share|improve this question



























      0












      0








      0








      This is my code:



      for i in range(0, row_count):
      if counter<row_count-1:
      lines.append(""" var flightPlanCoordinates = [
      {lat:""" + latitude[i] + """, lng: """ + longitude[i] + """}
      {lat:""" + latitude[i + 1] + """, lng: """ + longitude[i + 1] + """}
      ];
      """)
      lines.append("""var flightPath"""+i+""" = new google.maps.Polyline({
      path: flightPlanCoordinates,
      geodesic: true,
      strokeColor: '#FF0000',
      strokeOpacity: 1.0,
      strokeWeight: 5
      });""")
      counter += 1


      I'm trying to figure out why this isn't compiling(I'm getting a syntax error). This is a string that will be part of the code to an html page. I want to create i flight path variables, each named flightpathi. So flightpath0, flightpath1 and so forth. When using """+i+""" or any other variable inside triple quotations on other lines, this works. I know this is probably something pretty simple that I'm overlooking, but I'm stuck and I'd appreciate any help!










      share|improve this question
















      This is my code:



      for i in range(0, row_count):
      if counter<row_count-1:
      lines.append(""" var flightPlanCoordinates = [
      {lat:""" + latitude[i] + """, lng: """ + longitude[i] + """}
      {lat:""" + latitude[i + 1] + """, lng: """ + longitude[i + 1] + """}
      ];
      """)
      lines.append("""var flightPath"""+i+""" = new google.maps.Polyline({
      path: flightPlanCoordinates,
      geodesic: true,
      strokeColor: '#FF0000',
      strokeOpacity: 1.0,
      strokeWeight: 5
      });""")
      counter += 1


      I'm trying to figure out why this isn't compiling(I'm getting a syntax error). This is a string that will be part of the code to an html page. I want to create i flight path variables, each named flightpathi. So flightpath0, flightpath1 and so forth. When using """+i+""" or any other variable inside triple quotations on other lines, this works. I know this is probably something pretty simple that I'm overlooking, but I'm stuck and I'd appreciate any help!







      python html syntax-error quotation-marks






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 25 '18 at 8:11









      pizza static void main

      1,78411024




      1,78411024










      asked Nov 25 '18 at 1:03









      AminAmin

      11




      11
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Triple quotes are for multiline comments in python. I would use "var flightPath" + str(i). You may also want to look into enumerate for your loop. If you need the extra quotes as part of your string for some reason you need to escape them so they are not comments.






          share|improve this answer
























          • Thank you. And how can I escape them so they aren't comments ?

            – Amin
            Nov 25 '18 at 1:23











          • Here is post about it. stackoverflow.com/questions/6275762/escaping-quotes-in-string I would read the selected answer and the comments as there are some caveats when escaping quotes

            – Taylor
            Nov 25 '18 at 1:30











          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%2f53463804%2fpython-double-quotation-syntax-issue%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Triple quotes are for multiline comments in python. I would use "var flightPath" + str(i). You may also want to look into enumerate for your loop. If you need the extra quotes as part of your string for some reason you need to escape them so they are not comments.






          share|improve this answer
























          • Thank you. And how can I escape them so they aren't comments ?

            – Amin
            Nov 25 '18 at 1:23











          • Here is post about it. stackoverflow.com/questions/6275762/escaping-quotes-in-string I would read the selected answer and the comments as there are some caveats when escaping quotes

            – Taylor
            Nov 25 '18 at 1:30
















          0














          Triple quotes are for multiline comments in python. I would use "var flightPath" + str(i). You may also want to look into enumerate for your loop. If you need the extra quotes as part of your string for some reason you need to escape them so they are not comments.






          share|improve this answer
























          • Thank you. And how can I escape them so they aren't comments ?

            – Amin
            Nov 25 '18 at 1:23











          • Here is post about it. stackoverflow.com/questions/6275762/escaping-quotes-in-string I would read the selected answer and the comments as there are some caveats when escaping quotes

            – Taylor
            Nov 25 '18 at 1:30














          0












          0








          0







          Triple quotes are for multiline comments in python. I would use "var flightPath" + str(i). You may also want to look into enumerate for your loop. If you need the extra quotes as part of your string for some reason you need to escape them so they are not comments.






          share|improve this answer













          Triple quotes are for multiline comments in python. I would use "var flightPath" + str(i). You may also want to look into enumerate for your loop. If you need the extra quotes as part of your string for some reason you need to escape them so they are not comments.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 25 '18 at 1:17









          TaylorTaylor

          552316




          552316













          • Thank you. And how can I escape them so they aren't comments ?

            – Amin
            Nov 25 '18 at 1:23











          • Here is post about it. stackoverflow.com/questions/6275762/escaping-quotes-in-string I would read the selected answer and the comments as there are some caveats when escaping quotes

            – Taylor
            Nov 25 '18 at 1:30



















          • Thank you. And how can I escape them so they aren't comments ?

            – Amin
            Nov 25 '18 at 1:23











          • Here is post about it. stackoverflow.com/questions/6275762/escaping-quotes-in-string I would read the selected answer and the comments as there are some caveats when escaping quotes

            – Taylor
            Nov 25 '18 at 1:30

















          Thank you. And how can I escape them so they aren't comments ?

          – Amin
          Nov 25 '18 at 1:23





          Thank you. And how can I escape them so they aren't comments ?

          – Amin
          Nov 25 '18 at 1:23













          Here is post about it. stackoverflow.com/questions/6275762/escaping-quotes-in-string I would read the selected answer and the comments as there are some caveats when escaping quotes

          – Taylor
          Nov 25 '18 at 1:30





          Here is post about it. stackoverflow.com/questions/6275762/escaping-quotes-in-string I would read the selected answer and the comments as there are some caveats when escaping quotes

          – Taylor
          Nov 25 '18 at 1:30


















          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%2f53463804%2fpython-double-quotation-syntax-issue%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

          A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

          Calculate evaluation metrics using cross_val_predict sklearn

          Insert data from modal to MySQL (multiple modal on website)