code issue
given a number n, for each integer i in the range from 1 to n inclusive, print one value per line as follows: . if i is a multiple of both 3 but not 5, print fizz. .if i is a multiple of 5 but not 3, print buzz .if i is not a multiple of 3 or 5, print the value of i. the above is the question. the below is my answer, but it keeps saying I'm failing it and this is the output my code keeps giving me: it passes my input n (Which was 13) and starts to print from 1 again. please help - 1 - 2 - Fizz - 4 - Buzz - Fizz - 7 - 8 - Fizz - Buzz - 11 - Fizz - 13 - 1 - 2 - Fizz - 4 - Buzz - Fizz - 7 - 8 - Fizz - Buzz - 11 - Fizz - 13 - 14 - Fizzbuzz for i in range(1, n+1): if i % 3 == 0 and i % 5 == 0: print("Fizzbuzz") elif i % 3 == 0: print("Fizz") elif i % 5 == 0: print("Buzz") else: print(i) print(i, sep='\n') fizzbuzz(13) -- https://mail.python.org/mailman/listinfo/python-list
struggle to upgrade pip on visual studio code
hello, i successfully installed openpyxl but it is saying this about my pip: WARNING: You are using pip version 22.0.2; however, version 22.0.4 is available.You should consider upgrading via the 'C:\Program Files\Python310\python.exe -m pip install --upgrade pip' command. And then when I try to upgrade using 'C:\Program Files\Python310\python.exe -m pip install --upgrade pip command it says this: C:\Program : The term 'C:\Program' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + C:\Program Files\Python310\python.exe -m pip install --upgrade pip+ ~~ + CategoryInfo : ObjectNotFound: (C:\Program:String) [], Comma ndNotFoundException + FullyQualifiedErrorId : CommandNotFoundException please what do I do? -- https://mail.python.org/mailman/listinfo/python-list
upgrade pip
im trying to upgrade my pip so i can install openpyxl. i though i had successfully upgraded pip, and then I was trying to install openpyxl, but I was getting this: C:\Users\ojomo>"C:\Program Files\Python310\python.exe" -m pip install --upgrade Traceback (most recent call last): File "C:\Program Files\Python310\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Program Files\Python310\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "C:\Users\ojomo\AppData\Roaming\Python\Python310\site-packages\pip\__main__.py", line 29, in from pip._internal.cli.main import main as _main File "C:\Users\ojomo\AppData\Roaming\Python\Python310\site-packages\pip\_internal\cli\main.py", line 9, in from pip._internal.cli.autocompletion import autocomplete File "C:\Users\ojomo\AppData\Roaming\Python\Python310\site-packages\pip\_internal\cli\autocompletion.py", line 10, in from pip._internal.cli.main_parser import create_main_parser File "C:\Users\ojomo\AppData\Roaming\Python\Python310\site-packages\pip\_internal\cli\main_parser.py", line 8, in from pip._internal.cli import cmdoptions File "C:\Users\ojomo\AppData\Roaming\Python\Python310\site-packages\pip\_internal\cli\cmdoptions.py", line 23, in from pip._internal.cli.parser import ConfigOptionParser File "C:\Users\ojomo\AppData\Roaming\Python\Python310\site-packages\pip\_internal\cli\parser.py", line 12, in from pip._internal.configuration import Configuration, ConfigurationError File "C:\Users\ojomo\AppData\Roaming\Python\Python310\site-packages\pip\_internal\configuration.py", line 20, in from pip._internal.exceptions import ( File "C:\Users\ojomo\AppData\Roaming\Python\Python310\site-packages\pip\_internal\exceptions.py", line 13, in from pip._vendor.requests.models import Request, Response File "C:\Users\ojomo\AppData\Roaming\Python\Python310\site-packages\pip\_vendor\requests\__init__.py", line 43, in from pip._vendor import urllib3 ImportError: cannot import name 'urllib3' from 'pip._vendor' (C:\Users\ojomo\AppData\Roaming\Python\Python310\site-packages\pip\_vendor\__init__.py) and then I realised no matter what I type into the terminal (for example if I'm trying to check what version pip is, or I'm to import another module), it will print out this same specific lines of code. -- https://mail.python.org/mailman/listinfo/python-list
oop issue
i am trying to print this code but it keeps giving me this typeerror, please help. the csv file format i am trying to change into a list is in a different module. class invest_crypto: crypto_current_rate = 0.05 client_list = [] def __init__(self, name, surname, amount_Deposited, amount_to_transfer): self.name = name self.surname = surname self.amount_Deposited = amount_Deposited self.amount_to_transfer = amount_to_transfer invest_crypto.client_list.append(self) def calculate_customer_transfer(self): self.customer_transfer = (self.crypto_current_rate * self. amount_Deposited) + self.amount_Deposited return self.customer_transfer @classmethod def access_client_details(cls): with open('C:\\Users\\ojomo\\OneDrive\\Desktop\\myexcel\\ oop_learn.py\\myExperiment.py\\clientDetails.csv', 'r' ) as f: reader = csv.DictReader(f) clientDetails = list(reader) for item in clientDetails: invest_crypto( name=item.get('name'), surname=item.get('surname'), amount_Deposited=item.get('amount_deposited'), amount_to_transfer=item.get('amount_to_transfer') ) @staticmethod def __repr__(self): return f"('{self.name}', '{self.surname}', '{self.amount_Deposited}', '{self.amount_to_transfer}')" invest_crypto.access_client_details() print(invest_crypto.client_list()) -- https://mail.python.org/mailman/listinfo/python-list
oop issue
i just finished learning oop as a beginner and trying to practice with it but i ran into this typeerror issue, help please. Traceback (most recent call last): File "c:\Users\ojomo\OneDrive\Desktop\myexcel\oop_learn.py\myExperiment.py\mainMain.py", line 36, in print(invest_crypto.client_list) TypeError: invest_crypto.__repr__() missing 1 required positional argument: 'self' this is my code below: import csv class invest_crypto: crypto_current_rate = 0.05 client_list = [] def __init__(self, name, surname, amount_Deposited, amount_to_transfer): self.name = name self.surname = surname self.amount_Deposited = amount_Deposited self.amount_to_transfer = amount_to_transfer invest_crypto.client_list.append(self) def calculate_customer_transfer(self): self.customer_transfer = (self.crypto_current_rate * self. amount_Deposited) + self.amount_Deposited return self.customer_transfer @classmethod def access_client_details(cls): with open('C:\\Users\\ojomo\\OneDrive\\Desktop\\myexcel\\ oop_learn.py\\myExperiment.py\\clientDetails.csv', 'r' ) as f: reader = csv.DictReader(f) clientDetails = list(reader) for item in clientDetails: invest_crypto( name=item.get('name'), surname=item.get('surname'), amount_Deposited=item.get('amount_deposited'), amount_to_transfer=item.get('amount_to_transfer') ) @staticmethod def __repr__(self): return f"('{self.name}', '{self.surname}', '{self.amount_Deposited}', '{self.amount_to_transfer}')" invest_crypto.access_client_details() print(invest_crypto.client_list) -- https://mail.python.org/mailman/listinfo/python-list
code confusion
i = int(input()) lis = list(map(int,input().strip().split()))[:i] z = max(lis) while max(lis) == z: lis.remove(max(lis)) print (max(lis)) this is an answer to a question from the discussion chat in hackerrank. i didn't know the answer so i found an answer that fitted well to the question, however i struggle to understand the use of some of the methods and functions the person has used. my major questions are: 1. what does "[:i]" mean 2. is there another i could write this code using if statement? thank you -- https://mail.python.org/mailman/listinfo/python-list