Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: list.count does not appear to function
Post: RE: list.count does not appear to function

It is working good to me, mylist = [5, 12, 27, 3, 12, 5, 9, 5, 11] print(mylist.count(5)) print(mylist.count(3)) print(mylist) k=mylist.count(12) print(k)Output:C:\Users\sandeep\Downloads>py tes...
sandeep_ganga General Coding Help 7 1,074 Mar-16-2021, 10:45 AM
    Thread: Simple Palindrome
Post: RE: Simple Palindrome

reverse string works good to reduce iterations, def is_palindrome(i): if len(i) <= 1 or i.lower() == i[::-1].lower(): return True else: return False print(is_palindrome(...
sandeep_ganga General Coding Help 4 678 Nov-25-2020, 02:21 PM
    Thread: Beginner - Assistance please
Post: RE: Beginner - Assistance please

"for" will iterate over the given, thus try use "if" to direct compare and see if that helps reservation_name = input(f"\nGood afternoon, Anthony's dinner reservations. \n May I have your full name p...
sandeep_ganga General Coding Help 4 570 Nov-20-2020, 03:26 PM
    Thread: How to Filter a Dataframe
Post: RE: How to Filter a Dataframe

I doubt S_ID column had whitespaces, import pandas as pd df=pd.read_excel(open('b111.xlsx', 'rb'),sheet_name='Sheet1') print(df) #adding len coluumn df['id_char_length']=df['id'].astype(str).map(l...
sandeep_ganga Data Science 4 840 Nov-20-2020, 02:57 PM
    Thread: Single digits seem to be greater than double digits
Post: RE: Single digits seem to be greater than double d...

See below, i used to typecast to str only at print, rest comparisons in int. print('hello world!') print('What is your name?') name=input() print('That is a nice name, '+name) print('How old are you,...
sandeep_ganga General Coding Help 4 748 Nov-20-2020, 09:56 AM
    Thread: get two characters, count and print from a .txt file
Post: RE: get two characters, count and print from a .tx...

I tried something as below, see if it helps file = open('h.txt', 'r') for each in file: print (each) k=each.split() ###print(k) j=[] for i in k: ### print(i[:2]) j.append(i[:...
sandeep_ganga General Coding Help 9 1,103 Oct-03-2020, 06:23 AM
    Thread: How to change part of the value string in Python Dictionary?
Post: RE: How to change part of the value string in Pyth...

Try this to see if helps, recs = {1: ['Susan Smith', '[email protected]'], 2: ['Cole Brown', '[email protected]'], 3: ['Sue John', '[email protected]']} print(recs) temp=[] for key,val in recs.items(): f...
sandeep_ganga Homework 11 1,757 Feb-04-2020, 07:26 AM
    Thread: Please Help
Post: RE: Tip Calculator

try this to see if helps, first_name = input ("What is the servers name? ") price_meal = float(input("What is the check amount? ")) tip_p = float(input("Tip Percent? ")) tip=price_meal*(tip_p/100) pr...
sandeep_ganga Homework 4 903 Feb-03-2020, 07:51 AM
    Thread: Obtaining Correct Date In Pandas DataFrame
Post: RE: Obtaining Correct Date In Pandas DataFrame

Try this, converting object to datetime64 type display['DATE']= pd.to_datetime(display['DATE'],format='%Y-%m-%d') display['DATE']= pd.to_datetime(display['DATE']).dt.strftime('%d-%m-%Y') import pan...
sandeep_ganga Data Science 14 3,007 Jan-27-2020, 12:12 PM
    Thread: Problem keeping the window up
Post: RE: Problem keeping the window up

Try this to see if helps, both programs wont exit until we input match word defined in if block, and both act independent. #starter.py import subprocess import os from subprocess import Popen, CREAT...
sandeep_ganga General Coding Help 11 1,571 Jan-23-2020, 12:36 PM
    Thread: Substring and If then Condition to create column
Post: RE: Substring and If then Condition to create colu...

Try this to see if that helps, import pandas as pd df=pd.read_csv("ab.csv",header=0, names=['roadno']) print(df) data=[] for i in df['roadno']: if i[:1].lower()=="h" or i[:1].lower()=="m": #if i...
sandeep_ganga General Coding Help 2 930 Jan-23-2020, 08:35 AM
    Thread: Problem with accepting multiple string inputs
Post: RE: Problem with accepting multiple string inputs

try this to see if that helps, my_name = input("What is your name? ") my_secondname = input("What is your second name? ") age = int(input("What is your age? ")) measurement = input("What unit of me...
sandeep_ganga General Coding Help 5 1,165 Jan-22-2020, 05:18 PM
    Thread: Obtaining Correct Date In Pandas DataFrame
Post: RE: Obtaining Correct Date In Pandas DataFrame

Hi, I was finally able to manage install and use jupyter notebook. Google helped. python -m pip install jupyterlab python -m pip install jupyter python -m pip install notebook python -m notebook #it...
sandeep_ganga Data Science 14 3,007 Jan-22-2020, 04:47 PM
    Thread: If & Else statements not printing.
Post: RE: If & Else statements not printing.

I doubt indentation is erroring you, try below to see if that helps score=99 if score == 100: print(f"congrats, you reached {score}\n") else: print("Almost at 100\n")Output:python test1.py Almost ...
sandeep_ganga General Coding Help 3 947 Jan-22-2020, 04:38 PM
    Thread: Need help solving this
Post: RE: Need help solving this

try using below to see if that helps, from random import choice def choosedishes(days): count=0 while count < days: chosendish=choice(foodwelike) if chosendish not in mymenu: mymenu.appen...
sandeep_ganga General Coding Help 3 901 Jan-21-2020, 11:06 AM
    Thread: List items verification for Integer type
Post: RE: List items verification for Integer type

Try this to see if that helps, list1=['man12','11', '12', '14', '20', '21', '23', '24', 'man', '1', '27', '28', '29.1', '30'] mydefectlist=[] mydefectlist1=[] mydefectlist2=[] for item in list1: t...
sandeep_ganga General Coding Help 4 1,126 Jan-17-2020, 09:11 AM
    Thread: Loop does not work in python
Post: RE: Loop does not work in python

Not sure if i missed something, Given a set of N measurements, (r1, r2, . . . , rN ) - reflectance array we will initially assign the odd-numbered measurements to class 1 - find odd numbers, odd me...
sandeep_ganga Homework 11 2,164 Jan-13-2020, 03:43 PM
    Thread: Loop does not work in python
Post: RE: Loop does not work in python

It works good for any number of elements we pass, since we have for loop added to run till range of input given "totalsize=np.size(reflectance) for i in range(totalsize):" And the statement, "if (ref...
sandeep_ganga Homework 11 2,164 Jan-13-2020, 10:41 AM
    Thread: Loop does not work in python
Post: RE: Loop does not work in python

Can you try below to see if that helps, import numpy as np import math def find_nearest(array, value): array = np.asarray(array) idx = (np.abs(array - value)).argmin() return array[idx...
sandeep_ganga Homework 11 2,164 Jan-13-2020, 05:43 AM
    Thread: Rock, Paper, Scissors Game
Post: RE: Rock, Paper, Scissors Game

Try this to see if it helps, items=['paper','scissors','rock']# items list i=True while i==True: #read strings , convert lower p_1=input("\nenter player 1 choice: ").lower() p_2=input("enter playe...
sandeep_ganga Homework 2 2,193 Jan-10-2020, 07:14 AM

User Panel Messages

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