Python Forum
I am really confused with this error.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I am really confused with this error.
#1
I honestly have no idea what is going on or why my code will not work :(

import sys


first_num = int(sys.argv[1])
second_num = int(sys.argv[2]


if first_num + second_num <= 0:
    print('You have chosen the path of destitution.')
elif first_num + second_num is >= 1 and <= 100:
    print('You have chosen the path of plenty')
elif first_num + second_num > 100:
    print('You have chosen the path of excess.')
^This is the branching.py file which I am getting an error from^

\/For some reason this numbers.py file is being called as well which confuses the hell out of me\/

import sys


first_number = float(sys.argv[1])
second_number = float(sys.argv[2]) 


result_sum = first_number + second_number
result_difference = first_number - second_number
result_product = first_number * second_number
result_quotient = first_number / second_number

print(f"{first_number} plus {second_number} equals {result_sum}")
print(f"{first_number} minus {second_number} equals {result_difference}")
print(f"{first_number} multipied by {second_number} equals {result_product}")
print(f"{first_number} divided by {second_number} equals {result_quotient}")
\/In the Terminal you see it calls this numbers.py file that I did not run and then it gives me this weird error.\/

Error:
manus@Sys-Main:~/Python/Twilio$ python3 branching.py 20 20 20.0 plus 20.0 equals 40.0 20.0 minus 20.0 equals 0.0 20.0 multipied by 20.0 equals 400.0 20.0 divided by 20.0 equals 1.0 File "branching.py", line 8 if first_number + second_number <= 0: ^ SyntaxError: invalid syntax Error in sys.excepthook: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 72, in apport_excepthook from apport.fileutils import likely_packaged, get_recent_crashes File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module> from apport.report import Report File "/usr/lib/python3/dist-packages/apport/report.py", line 32, in <module> import apport.fileutils File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 12, in <module> import os, glob, subprocess, os.path, time, pwd, sys, requests_unixsocket File "/usr/lib/python3/dist-packages/requests_unixsocket/__init__.py", line 1, in <module> import requests File "/usr/lib/python3/dist-packages/requests/__init__.py", line 112, in <module> from . import utils File "/usr/lib/python3/dist-packages/requests/utils.py", line 26, in <module> from ._internal_utils import to_native_string File "/usr/lib/python3/dist-packages/requests/_internal_utils.py", line 11, in <module> from .compat import is_py2, builtin_str, str File "/usr/lib/python3/dist-packages/requests/compat.py", line 29, in <module> import simplejson as json File "/usr/lib/python3/dist-packages/simplejson/__init__.py", line 110, in <module> from decimal import Decimal File "/usr/lib/python3.8/decimal.py", line 3, in <module> from _decimal import * AttributeError: module 'numbers' has no attribute 'Number' Original exception was: File "branching.py", line 8 if first_number + second_number <= 0: ^ SyntaxError: invalid syntax
Reply


Messages In This Thread
I am really confused with this error. - by Runar - Sep-14-2020, 09:12 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  String int confused janeik 7 1,083 Aug-02-2023, 01:26 AM
Last Post: deanhystad
  I am confused with the key and value thing james1019 3 967 Feb-22-2023, 10:43 PM
Last Post: deanhystad
  Pandas confused DPaul 6 2,562 Sep-19-2021, 06:45 AM
Last Post: DPaul
  is and '==' i'm confused hshivaraj 6 2,716 Sep-15-2021, 09:45 AM
Last Post: snippsat
  Confused with 'flags' tester_V 10 4,918 Apr-12-2021, 03:03 AM
Last Post: tester_V
  Simple Tic Tac Toe but I'm confused Izith 1 2,195 Sep-26-2020, 04:42 PM
Last Post: Larz60+
  Confused on how to go about writing this or doing this... pythonforumuser 3 2,492 Feb-10-2020, 09:15 AM
Last Post: snippsat
  Dazed and confused... RodNintendeaux 10 7,506 May-28-2017, 01:32 PM
Last Post: sparkz_alot

Forum Jump:

User Panel Messages

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