##### I have no clue what I am doing wrong here
 I have no clue what I am doing wrong here elroberto Programmer named Tim Posts: 5 Threads: 3 Joined: Jun 2022 Reputation: Jun-18-2022, 05:52 AM (This post was last modified: Jun-19-2022, 06:56 AM by Yoriz. Edit Reason: Added code tags ) Code Version 1: ```message="Thank You for Choosing Robert's Fiberoptics! The One-Stop-Shop for all your fiberoptics needs!" print(message) amount_of_cable=input("Please enter the desired amount of fiberoptic cable needed for your project: ") float(amount_of_cable)#I think I'm doing something wrong here if amount_of_cable<100: def multiply(amount_of_cable,b): result=int(amount_of_cable)*0.87 return result print(multiply(amount_of_cable,0.87))```When Ran in Console: ``````Error:Thank You for Choosing Robert's Fiberoptics! The One-Stop-Shop for all your fiberoptics needs! Please enter the desired amount of fiberoptic cable needed for your project: 50 Traceback (most recent call last): File "main.py", line 6, in if amount_of_cable<100: TypeError: '<' not supported between instances of 'str' and 'int'``````Code Version 2 (Attempted Solution): ```message="Thank You for Choosing Robert's Fiberoptics! The One-Stop-Shop for all your fiberoptics needs!" print(message) amount_of_cable=int(input("Please enter the desired amount of fiberoptic cable needed for your project: ")) #I think I'm doing 5. something wrong here if amount_of_cable<100: def multiply(amount_of_cable,b): result=int(amount_of_cable)*0.87 return result print(multiply(amount_of_cable,0.87)) print(amount_of_cable,"Is this correct? Please say 'Yes, or No'") question=input("Please say Yes, or No: ") #Test this in Replit!!!```When Ran in Console: ``````Output:Thank You for Choosing Robert's Fiberoptics! The One-Stop-Shop for all your fiberoptics needs! Please enter the desired amount of fiberoptic cable needed for your project: 50 50 Is this correct? Please say 'Yes, or No' Please say Yes, or No: Yes``````No error message regarding the if statement, but it looks like it just skipped over it. What am I doing wrong? All I'm trying to do is get the number that is set to the `amount_of_cable` variable to be recognized as less than 100, and then multiply that same number by 0.87 Yoriz write Jun-19-2022, 06:56 AM:Please post all code, output and errors (In their entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button. Reply Posts: 1,822 Threads: 2 Joined: Apr 2017 Reputation: Jun-18-2022, 06:01 AM Please format your code properly - put it within "[python]" tags, as that will add line numbering for you, preserve indentation and add syntax highlighting. As it is, it's really hard to read. Reply rob101 Minister of Silly Walks Posts: 456 Threads: 16 Joined: Jun 2022 Reputation: Jun-18-2022, 08:09 AM (This post was last modified: Jun-18-2022, 08:09 AM by rob101.) First off, as already posted: please use the code tags You don't need to define `message`. You can simply `print("Thank you...")` Move the custom function out of the `if` branch: it should the first thing in your code block edit: in fact, as is, I can't see that you even need your custom function, but post back when you've made the changes and we'll take it from there. Sig: >>> import this The UNIX philosophy: "Do one thing, and do it well." "The danger of computers becoming like humans is not as great as the danger of humans becoming like computers." :~ Konrad Zuse "Everything should be made as simple as possible, but not simpler." :~ Albert Einstein Reply BashBedlam Minister of Silly Walks Posts: 371 Threads: 2 Joined: Jan 2021 Reputation: Jun-18-2022, 06:04 PM Try it like this: ```def multiply(amount_of_cable,b): result=int(amount_of_cable)*0.87 return result message="Thank You for Choosing Robert's Fiberoptics! The One-Stop-Shop for all your fiberoptics needs!" print(message) amount_of_cable=int(input("Please enter the desired amount of fiberoptic cable needed for your project: ")) #I think I'm doing 5. something wrong here if amount_of_cable<100: print(multiply(amount_of_cable,0.87)) print(amount_of_cable,"Is this correct? Please say 'Yes, or No'") question=input("Please say Yes, or No: ") #Test this in Replit!!!``` Reply Posts: 6,196 Threads: 16 Joined: Feb 2020 Reputation: Jun-18-2022, 08:56 PM While this is legal Python code: ```amount_of_cable = 100 if amount_of_cable < 100: def multiply(amount_of_cable,b): result=int(amount_of_cable)*0.87 return result```It is very unusual code, and it does not do what you think it does. This defines a function: ```def multiply(amount_of_cable): return amount_of_cable * 0.87```Now that the function is defined you can use it in your program. Like this: ```if amount_of_cable < 100: price = multiply(amount_of_cable):```In your program the if statement controlled if the function was defined, not if it was used. If amount of cable >= 100 the function is not defined and it was not called. If the amount of cable < 100 the function was defined, but not used. Neither result are what you want. Reply

 Possibly Related Threads… Thread Author Replies Views Last Post Am I wrong or is Udemy wrong? String Slicing! Mavoz 3 2,527 Nov-05-2022, 11:33 AM Last Post: Mavoz Can I get a clue about testing please? Mustey 8 3,646 Apr-12-2021, 04:45 PM Last Post: Larz60+ I haven't a clue how to implement this logic 357mag 3 2,105 Apr-02-2020, 04:35 PM Last Post: 357mag python gives wrong string length and wrong character thienson30 2 2,983 Oct-15-2019, 08:54 PM Last Post: Gribouillis Getting syntax error, no clue why KaynRyu 4 3,119 Mar-26-2019, 02:43 PM Last Post: KaynRyu I have no clue whats wrong... Jack_03 1 2,810 Sep-28-2017, 05:36 PM Last Post: nilamo

Forum Jump:

### User Panel Messages

##### Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020