Erroneous space at end of code between $ and output












0












$begingroup$


I have a code that I am losing out on getting points simply because the very last line for some odd reason is giving me a space between the $ and the output. I have checked for stupid fat finger mistakes but I am finding nothing. Can someone who is much more experienced help me out here? This is driving me insane!



import math

# Dictionary of paint colors and cost per gallon
paintColors = {
'red': 35,
'blue': 25,
'green': 23
}

# FIXME (1): Prompt user to input wall's width
# Calculate and output wall area
wallHeight = float(input('Enter wall height (feet): n'))
wallWidth = float(input('Enter wall width (feet): n'))

wallArea = float((wallHeight) * (wallWidth))

print('Wall area:', wallArea, 'square feet')

# FIXME (2): Calculate and output the amount of paint in gallons needed to paint the wall

paint_gallons = ((wallArea) / 350)

print('Paint needed:', paint_gallons, 'gallons')

# FIXME (3): Calculate and output the number of 1 gallon cans needed to paint the wall, rounded up to nearest integer

paint_cans = math.ceil(paint_gallons)

print('Cans needed:', paint_cans, 'can(s)n')

# FIXME (4): Calculate and output the total cost of paint can needed depending on color

wallColor = input('Choose a color to paint the wall: n')

paint_colors = {
'red' : 35,
'blue' : 25,
'green' : 23
}

if wallColor in 'red':
paint_cost = (paint_colors['red'] * (paint_cans))

if wallColor in 'blue':
paint_cost = (paint_colors['blue'] * (paint_cans))

if wallColor in 'green':
paint_cost = (paint_colors['green'] * (paint_cans))

print('Cost of purchasing', wallColor, 'paint: $', paint_cost)


(Also, I have created what I needed for the user input and the dictionary output to relate, but it is a very long-winded way about it. How do I streamline this code for the future? To be clear, the user would input a color to paint their wall and the dictionary would use that to generate the cost per gallon to be calculated in the code below the dict inputs. I am wondering how to do this same thing without having to type out every single dict entry and instead just have it link to the int associated with the dict entry.)










share|improve this question







New contributor




Shay is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$

















    0












    $begingroup$


    I have a code that I am losing out on getting points simply because the very last line for some odd reason is giving me a space between the $ and the output. I have checked for stupid fat finger mistakes but I am finding nothing. Can someone who is much more experienced help me out here? This is driving me insane!



    import math

    # Dictionary of paint colors and cost per gallon
    paintColors = {
    'red': 35,
    'blue': 25,
    'green': 23
    }

    # FIXME (1): Prompt user to input wall's width
    # Calculate and output wall area
    wallHeight = float(input('Enter wall height (feet): n'))
    wallWidth = float(input('Enter wall width (feet): n'))

    wallArea = float((wallHeight) * (wallWidth))

    print('Wall area:', wallArea, 'square feet')

    # FIXME (2): Calculate and output the amount of paint in gallons needed to paint the wall

    paint_gallons = ((wallArea) / 350)

    print('Paint needed:', paint_gallons, 'gallons')

    # FIXME (3): Calculate and output the number of 1 gallon cans needed to paint the wall, rounded up to nearest integer

    paint_cans = math.ceil(paint_gallons)

    print('Cans needed:', paint_cans, 'can(s)n')

    # FIXME (4): Calculate and output the total cost of paint can needed depending on color

    wallColor = input('Choose a color to paint the wall: n')

    paint_colors = {
    'red' : 35,
    'blue' : 25,
    'green' : 23
    }

    if wallColor in 'red':
    paint_cost = (paint_colors['red'] * (paint_cans))

    if wallColor in 'blue':
    paint_cost = (paint_colors['blue'] * (paint_cans))

    if wallColor in 'green':
    paint_cost = (paint_colors['green'] * (paint_cans))

    print('Cost of purchasing', wallColor, 'paint: $', paint_cost)


    (Also, I have created what I needed for the user input and the dictionary output to relate, but it is a very long-winded way about it. How do I streamline this code for the future? To be clear, the user would input a color to paint their wall and the dictionary would use that to generate the cost per gallon to be calculated in the code below the dict inputs. I am wondering how to do this same thing without having to type out every single dict entry and instead just have it link to the int associated with the dict entry.)










    share|improve this question







    New contributor




    Shay is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.







    $endgroup$















      0












      0








      0





      $begingroup$


      I have a code that I am losing out on getting points simply because the very last line for some odd reason is giving me a space between the $ and the output. I have checked for stupid fat finger mistakes but I am finding nothing. Can someone who is much more experienced help me out here? This is driving me insane!



      import math

      # Dictionary of paint colors and cost per gallon
      paintColors = {
      'red': 35,
      'blue': 25,
      'green': 23
      }

      # FIXME (1): Prompt user to input wall's width
      # Calculate and output wall area
      wallHeight = float(input('Enter wall height (feet): n'))
      wallWidth = float(input('Enter wall width (feet): n'))

      wallArea = float((wallHeight) * (wallWidth))

      print('Wall area:', wallArea, 'square feet')

      # FIXME (2): Calculate and output the amount of paint in gallons needed to paint the wall

      paint_gallons = ((wallArea) / 350)

      print('Paint needed:', paint_gallons, 'gallons')

      # FIXME (3): Calculate and output the number of 1 gallon cans needed to paint the wall, rounded up to nearest integer

      paint_cans = math.ceil(paint_gallons)

      print('Cans needed:', paint_cans, 'can(s)n')

      # FIXME (4): Calculate and output the total cost of paint can needed depending on color

      wallColor = input('Choose a color to paint the wall: n')

      paint_colors = {
      'red' : 35,
      'blue' : 25,
      'green' : 23
      }

      if wallColor in 'red':
      paint_cost = (paint_colors['red'] * (paint_cans))

      if wallColor in 'blue':
      paint_cost = (paint_colors['blue'] * (paint_cans))

      if wallColor in 'green':
      paint_cost = (paint_colors['green'] * (paint_cans))

      print('Cost of purchasing', wallColor, 'paint: $', paint_cost)


      (Also, I have created what I needed for the user input and the dictionary output to relate, but it is a very long-winded way about it. How do I streamline this code for the future? To be clear, the user would input a color to paint their wall and the dictionary would use that to generate the cost per gallon to be calculated in the code below the dict inputs. I am wondering how to do this same thing without having to type out every single dict entry and instead just have it link to the int associated with the dict entry.)










      share|improve this question







      New contributor




      Shay is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.







      $endgroup$




      I have a code that I am losing out on getting points simply because the very last line for some odd reason is giving me a space between the $ and the output. I have checked for stupid fat finger mistakes but I am finding nothing. Can someone who is much more experienced help me out here? This is driving me insane!



      import math

      # Dictionary of paint colors and cost per gallon
      paintColors = {
      'red': 35,
      'blue': 25,
      'green': 23
      }

      # FIXME (1): Prompt user to input wall's width
      # Calculate and output wall area
      wallHeight = float(input('Enter wall height (feet): n'))
      wallWidth = float(input('Enter wall width (feet): n'))

      wallArea = float((wallHeight) * (wallWidth))

      print('Wall area:', wallArea, 'square feet')

      # FIXME (2): Calculate and output the amount of paint in gallons needed to paint the wall

      paint_gallons = ((wallArea) / 350)

      print('Paint needed:', paint_gallons, 'gallons')

      # FIXME (3): Calculate and output the number of 1 gallon cans needed to paint the wall, rounded up to nearest integer

      paint_cans = math.ceil(paint_gallons)

      print('Cans needed:', paint_cans, 'can(s)n')

      # FIXME (4): Calculate and output the total cost of paint can needed depending on color

      wallColor = input('Choose a color to paint the wall: n')

      paint_colors = {
      'red' : 35,
      'blue' : 25,
      'green' : 23
      }

      if wallColor in 'red':
      paint_cost = (paint_colors['red'] * (paint_cans))

      if wallColor in 'blue':
      paint_cost = (paint_colors['blue'] * (paint_cans))

      if wallColor in 'green':
      paint_cost = (paint_colors['green'] * (paint_cans))

      print('Cost of purchasing', wallColor, 'paint: $', paint_cost)


      (Also, I have created what I needed for the user input and the dictionary output to relate, but it is a very long-winded way about it. How do I streamline this code for the future? To be clear, the user would input a color to paint their wall and the dictionary would use that to generate the cost per gallon to be calculated in the code below the dict inputs. I am wondering how to do this same thing without having to type out every single dict entry and instead just have it link to the int associated with the dict entry.)







      python-3.x






      share|improve this question







      New contributor




      Shay is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      Shay is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      Shay is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 13 mins ago









      ShayShay

      1




      1




      New contributor




      Shay is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Shay is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Shay is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          0






          active

          oldest

          votes











          Your Answer





          StackExchange.ifUsing("editor", function () {
          return StackExchange.using("mathjaxEditing", function () {
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
          });
          });
          }, "mathjax-editing");

          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: "196"
          };
          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: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          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
          });


          }
          });






          Shay is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f211968%2ferroneous-space-at-end-of-code-between-and-output%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          Shay is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          Shay is a new contributor. Be nice, and check out our Code of Conduct.













          Shay is a new contributor. Be nice, and check out our Code of Conduct.












          Shay is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Code Review Stack Exchange!


          • 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.


          Use MathJax to format equations. MathJax reference.


          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%2fcodereview.stackexchange.com%2fquestions%2f211968%2ferroneous-space-at-end-of-code-between-and-output%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

          404 Error Contact Form 7 ajax form submitting

          How to know if a Active Directory user can login interactively

          Refactoring coordinates for Minecraft Pi buildings written in Python