For loop doesn't go all around a dictionary - python

so i have the code down below
import requests
import json
with open("forex_rates.json", "r") as file:
rate = json.load(file)
nrate = rate
Base = input("enter your base currency: ")
if Base not in rate["rates"]:
print("That's not a valid currency...")
Base = input("enter your base currency: ")
with open("forex_rates.json", "r") as file:
nrate["base"] = Base
for i in rate["rates"]:
nrate["rates"][i] = rate["rates"].get(i) / rate["rates"].get(Base)
print(nrate["rates"])
I'm trying to make a program that converts different currencies, for example:
1 EUR --> 1.18 USD
and in order to do this I have to edit the forex rates everytime depending on the base value
when i finished up the code i ran t and it worked all fine and it converted all values until it hit the same value in the forex value file
like if i convert from USD it will change all currency values depending on USD but when it hits the USD in the file the loop breaks
i tried for so long 'till i tried moving USD to the very bottom of the file as there is nothing after it to break. and it worked but that's for USD only.
when i change the base value inside the program it breaks again
for people saying the code isn't even finished i'd say that i almost finished this part of the program the converting part which i believe the most difficult and any other code left is only the GUI and some multiplying math
and i'll list the forex data below
#sorry if it's too big
{
"success":true,
"timestamp":1597402446,
"base":"EUR",
"date":"2020-08-14",
"rates":{
"AED":4.335266,
"AFN":91.176403,
"ALL":123.979569,
"AMD":572.651268,
"ANG":2.125143,
"AOA":695.22591,
"ARS":86.213707,
"AUD":1.651881,
"AWG":2.124558,
"AZN":2.001576,
"BAM":1.954795,
"BBD":2.390258,
"BDT":100.546318,
"BGN":1.956895,
"BHD":0.444938,
"BIF":2283.56194,
"BMD":1.18031,
"BND":1.622912,
"BOB":8.173103,
"BRL":6.336422,
"BSD":1.183874,
"BTC":0.0001,
"BTN":88.576746,
"BWP":13.863097,
"BYN":2.914727,
"BYR":23134.077322,
"BZD":2.38624,
"CAD":1.562064,
"CDF":2302.785095,
"CHF":1.074967,
"CLF":0.033942,
"CLP":936.574514,
"CNY":8.203627,
"COP":4452.129574,
"CRC":704.672423,
"CUC":1.18031,
"CUP":31.278217,
"CVE":110.201987,
"CZK":26.106129,
"DJF":210.746982,
"DKK":7.446693,
"DOP":69.149105,
"DZD":151.514114,
"EGP":18.805169,
"ERN":17.704664,
"ETB":42.448715,
"EUR":1,
"FJD":2.523208,
"FKP":0.90119,
"GBP":0.900976,
"GEL":3.647475,
"GGP":0.90119,
"GHS":6.811663,
"GIP":0.90119,
"GMD":61.163652,
"GNF":11418.288925,
"GTQ":9.116687,
"GYD":247.470583,
"HKD":9.14817,
"HNL":29.203723,
"HRK":7.531326,
"HTG":132.978265,
"HUF":346.161502,
"IDR":17595.177253,
"ILS":4.019203,
"IMP":0.90119,
"INR":88.434024,
"IQD":1413.229387,
"IRR":49696.95603,
"ISK":161.076893,
"JEP":0.90119,
"JMD":176.632894,
"JOD":0.836814,
"JPY":125.951475,
"KES":127.822789,
"KGS":92.238283,
"KHR":4859.521032,
"KMF":491.421896,
"KPW":1062.314938,
"KRW":1401.210938,
"KWD":0.360975,
"KYD":0.986486,
"KZT":496.331879,
"LAK":10752.381531,
"LBP":1789.879783,
"LKR":216.488093,
"LRD":235.294815,
"LSL":20.549263,
"LTL":3.485149,
"LVL":0.713958,
"LYD":1.626859,
"MAD":10.913322,
"MDL":19.82872,
"MGA":4566.909302,
"MKD":61.58448,
"MMK":1610.391686,
"MNT":3362.205621,
"MOP":9.449856,
"MRO":421.37087,
"MUR":46.799002,
"MVR":18.243058,
"MWK":879.737053,
"MXN":26.199071,
"MYR":4.949633,
"MZN":83.979304,
"NAD":20.548996,
"NGN":449.107914,
"NIO":41.242296,
"NOK":10.544902,
"NPR":141.752962,
"NZD":1.80663,
"OMR":0.454403,
"PAB":1.183663,
"PEN":4.2222,
"PGK":4.165565,
"PHP":57.516411,
"PKR":199.282277,
"PLN":4.396536,
"PYG":8227.988848,
"QAR":4.297547,
"RON":4.835722,
"RSD":117.576625,
"RUB":86.625365,
"RWF":1142.595148,
"SAR":4.426709,
"SBD":9.756128,
"SCR":21.044237,
"SDG":65.300702,
"SEK":10.291595,
"SGD":1.620105,
"SHP":0.90119,
"SLL":11537.53114,
"SOS":689.301231,
"SRD":8.802808,
"STD":25132.067341,
"SVC":10.358743,
"SYP":603.981109,
"SZL":20.627972,
"THB":36.753085,
"TJS":12.208818,
"TMT":4.131085,
"TND":3.240537,
"TOP":2.698542,
"TRY":8.706498,
"TTD":8.006077,
"TWD":34.707966,
"TZS":2744.220413,
"UAH":32.433598,
"UGX":4343.852885,
"USD":1.18031,
"UYU":50.261259,
"UZS":12111.300903,
"VEF":11.788346,
"VND":27353.095658,
"VUV":134.283098,
"WST":3.09309,
"XAF":655.754247,
"XAG":0.044343,
"XAU":0.000606,
"XCD":3.189847,
"XDR":0.840933,
"XOF":655.720927,
"XPF":119.624668,
"YER":295.426891,
"ZAR":20.617975,
"ZMK":10624.212769,
"ZMW":21.85909,
"ZWL":380.05997
}
}

Related

How to get a certain value from a text file

I want to get a value from an API. However I am unable to tell Python what I want to do.
This is my current code:
response = requests.get('https://sms-service-online.com/api/getServicesAndCost/?country=0&operator=any&lang=en')
data = response.json()
plain = data["data"]
However the data which I want to display in my script is in the ["data"] part of the json. It is kind of a json inside a json.
For example: with
print(plain)
I would recieve this data:
[{"cost":"0.45","id":0,"servise":"VK.com","serviseImg":"bg-vk","number":"Numbers: 3047","value":"vk"},{"cost":"0.07","id":1,"servise":"OK.ru","serviseImg":"bg-ok","number":"Numbers: 14397","value":"ok"},{"cost":"0.15","id":2,"servise":"Whatsapp","serviseImg":"bg-wa","number":"Numbers: 17610","value":"wa"},{"cost":"0.18","id":3,"servise":"Viber","serviseImg":"bg-vi","number":"Numbers: 413","value":"vi"},{"cost":"0.00","id":4,"servise":"Telegram","serviseImg":"bg-tg","number":"Numbers: 0","value":"tg"},{"cost":"0.30","id":5,"servise":"WeChat","serviseImg":"bg-wb","number":"Numbers: 28389","value":"wb"},{"cost":"0.15","id":6,"servise":"Google,youtube,Gmail","serviseImg":"bg-go","number":"Numbers: 15419","value":"go"},{"cost":"0.11","id":7,"servise":"avito","serviseImg":"bg-av","number":"Numbers: 17379","value":"av"},{"cost":"0.07","id":8,"servise":"facebook","serviseImg":"bg-fb","number":"Numbers: 21636","value":"fb"},{"cost":"0.03","id":9,"servise":"Twitter","serviseImg":"bg-tw","number":"Numbers: 26864","value":"tw"},{"cost":"0.05","id":10,"servise":"Uber","serviseImg":"bg-ub","number":"Numbers: 20975","value":"ub"},{"cost":"0.22","id":11,"servise":"Qiwi","serviseImg":"bg-qw","number":"Numbers: 20371","value":"qw"},{"cost":"0.02","id":12,"servise":"Gett","serviseImg":"bg-gt","number":"Numbers: 28501","value":"gt"},{"cost":"0.00","id":13,"servise":"OLX","serviseImg":"bg-sn","number":"Numbers: 0","value":"sn"},{"cost":"0.14","id":14,"servise":"Instagram","serviseImg":"bg-ig","number":"Numbers: 3799","value":"ig"},{"cost":"0.00","id":15,"servise":"Hezzl","serviseImg":"bg-ss","number":"Numbers: 0","value":"ss"},{"cost":"0.07","id":16,"servise":"\u042e\u043b\u0430","serviseImg":"bg-ym","number":"Numbers: 17597","value":"ym"},{"cost":"0.03","id":17,"servise":"Mail.ru","serviseImg":"bg-ma","number":"Numbers: 17936","value":"ma"},{"cost":"0.03","id":18,"servise":"Microsoft","serviseImg":"bg-mm","number":"Numbers: 3830","value":"mm"},{"cost":"0.03","id":19,"servise":"Airbnb","serviseImg":"bg-uk","number":"Numbers: 28266","value":"uk"},{"cost":"0.00","id":20,"servise":"Line messenger","serviseImg":"bg-me","number":"Numbers: 0","value":"me"},{"cost":"0.03","id":21,"servise":"Yahoo","serviseImg":"bg-mb","number":"Numbers: 19077","value":"mb"},{"cost":"0.00","id":22,"servise":"Drugvokrug.ru","serviseImg":"bg-we","number":"Numbers: 0","value":"we"},{"cost":"0.05","id":23,"servise":"5ka.ru","serviseImg":"bg-bd","number":"Numbers: 27541","value":"bd"},{"cost":"0.00","id":24,"servise":"HQ Trivia","serviseImg":"bg-kp","number":"Numbers: 0","value":"kp"},{"cost":"0.65","id":25,"servise":"Delivery Club","serviseImg":"bg-dt","number":"Numbers: 26812","value":"dt"},{"cost":"0.03","id":26,"servise":"Yandex","serviseImg":"bg-ya","number":"Numbers: 20944","value":"ya"},{"cost":"0.05","id":27,"servise":"Steam","serviseImg":"bg-mt","number":"Numbers: 28121","value":"mt"},{"cost":"0.04","id":28,"servise":"Tinder","serviseImg":"bg-oi","number":"Numbers: 27478","value":"oi"},{"cost":"0.02","id":29,"servise":"Mamba, MeetMe","serviseImg":"bg-fd","number":"Numbers: 25328","value":"fd"},{"cost":"0.00","id":30,"servise":"Dent","serviseImg":"bg-zz","number":"Numbers: 0","value":"zz"},{"cost":"0.07","id":31,"servise":"KakaoTalk","serviseImg":"bg-kt","number":"Numbers: 27823","value":"kt"},{"cost":"0.04","id":32,"servise":"AOL","serviseImg":"bg-pm","number":"Numbers: 23369","value":"pm"},{"cost":"0.02","id":33,"servise":"LinkedIN","serviseImg":"bg-tn","number":"Numbers: 32192","value":"tn"},{"cost":"0.03","id":34,"servise":"Tencent QQ","serviseImg":"bg-qq","number":"Numbers: 27883","value":"qq"},{"cost":"0.06","id":35,"servise":"Magnit","serviseImg":"bg-mg","number":"Numbers: 993","value":"mg"},{"cost":"0.00","id":36,"servise":"pof.com","serviseImg":"bg-pf","number":"Numbers: 0","value":"pf"},{"cost":"0.03","id":37,"servise":"Yalla","serviseImg":"bg-yl","number":"Numbers: 27822","value":"yl"},{"cost":"0.00","id":38,"servise":"kolesa.kz","serviseImg":"bg-kl","number":"Numbers: 0","value":"kl"},{"cost":"0.03","id":39,"servise":"premium.one","serviseImg":"bg-po","number":"Numbers: 25869","value":"po"},{"cost":"0.07","id":40,"servise":"Naver","serviseImg":"bg-nv","number":"Numbers: 27582","value":"nv"},{"cost":"0.03","id":41,"servise":"Netflix","serviseImg":"bg-nf","number":"Numbers: 27715","value":"nf"},{"cost":"0.00","id":42,"servise":"icq","serviseImg":"bg-iq","number":"Numbers: 0","value":"iq"},{"cost":"0.00","id":43,"servise":"Onlinerby","serviseImg":"bg-ob","number":"Numbers: 0","value":"ob"},{"cost":"0.00","id":44,"servise":"kufarby","serviseImg":"bg-kb","number":"Numbers: 0","value":"kb"},{"cost":"0.03","id":45,"servise":"Imo","serviseImg":"bg-im","number":"Numbers: 25198","value":"im"},{"cost":"0.00","id":46,"servise":"Michat","serviseImg":"bg-mc","number":"Numbers: 0","value":"mc"},{"cost":"0.03","id":47,"servise":"Discord","serviseImg":"bg-ds","number":"Numbers: 22011","value":"ds"},{"cost":"0.00","id":48,"servise":"Seosprint","serviseImg":"bg-vv","number":"Numbers: 0","value":"vv"},{"cost":"0.00","id":49,"servise":"Monobank","serviseImg":"bg-ji","number":"Numbers: 0","value":"ji"},{"cost":"0.03","id":50,"servise":"TikTok\/Douyin","serviseImg":"bg-lf","number":"Numbers: 26299","value":"lf"},{"cost":"0.00","id":51,"servise":"Ukrnet","serviseImg":"bg-hu","number":"Numbers: 0","value":"hu"},{"cost":"0.00","id":52,"servise":"Skout","serviseImg":"bg-wg","number":"Numbers: 0","value":"wg"},{"cost":"0.00","id":53,"servise":"EasyPay","serviseImg":"bg-rz","number":"Numbers: 0","value":"rz"},{"cost":"0.00","id":54,"servise":"Q12 Trivia","serviseImg":"bg-vf","number":"Numbers: 0","value":"vf"},{"cost":"0.00","id":55,"servise":"Pyro Music","serviseImg":"bg-ny","number":"Numbers: 0","value":"ny"},{"cost":"0.00","id":56,"servise":"Wolt","serviseImg":"bg-rr","number":"Numbers: 0","value":"rr"},{"cost":"0.00","id":57,"servise":"CliQQ","serviseImg":"bg-fe","number":"Numbers: 0","value":"fe"},{"cost":"0.00","id":58,"servise":"ssoidnet","serviseImg":"bg-la","number":"Numbers: 0","value":"la"},{"cost":"0.00","id":59,"servise":"Zoho","serviseImg":"bg-zh","number":"Numbers: 0","value":"zh"},{"cost":"0.00","id":60,"servise":"Ticketmaster","serviseImg":"bg-gp","number":"Numbers: 0","value":"gp"},{"cost":"0.05","id":61,"servise":"Amazon","serviseImg":"bg-am","number":"Numbers: 25313","value":"am"},{"cost":"0.00","id":62,"servise":"Olacabs","serviseImg":"bg-ly","number":"Numbers: 0","value":"ly"},{"cost":"0.00","id":63,"servise":"Rambler","serviseImg":"bg-tc","number":"Numbers: 0","value":"tc"},{"cost":"0.02","id":64,"servise":"ProtonMail","serviseImg":"bg-dp","number":"Numbers: 30668","value":"dp"},{"cost":"0.00","id":65,"servise":"NRJ Music Awards","serviseImg":"bg-pg","number":"Numbers: 0","value":"pg"},{"cost":"0.03","id":66,"servise":"Citymobil","serviseImg":"bg-yf","number":"Numbers: 26997","value":"yf"},{"cost":"0.00","id":67,"servise":"MIRATORG","serviseImg":"bg-op","number":"Numbers: 0","value":"op"},{"cost":"0.03","id":68,"servise":"PGbonus","serviseImg":"bg-fx","number":"Numbers: 27563","value":"fx"},{"cost":"0.03","id":69,"servise":"MEGA","serviseImg":"bg-qr","number":"Numbers: 27848","value":"qr"},{"cost":"0.03","id":70,"servise":"SportMaster","serviseImg":"bg-yk","number":"Numbers: 26584","value":"yk"},{"cost":"0.03","id":71,"servise":"Careem","serviseImg":"bg-ls","number":"Numbers: 27873","value":"ls"},{"cost":"0.03","id":72,"servise":"BIGO LIVE","serviseImg":"bg-bl","number":"Numbers: 25421","value":"bl"},{"cost":"0.03","id":73,"servise":"MyMusicTaste","serviseImg":"bg-mu","number":"Numbers: 27898","value":"mu"},{"cost":"0.03","id":74,"servise":"Snapchat","serviseImg":"bg-fu","number":"Numbers: 27758","value":"fu"},{"cost":"0.00","id":75,"servise":"Keybase","serviseImg":"bg-bf","number":"Numbers: 0","value":"bf"},{"cost":"0.03","id":76,"servise":"OZON","serviseImg":"bg-sg","number":"Numbers: 26595","value":"sg"},{"cost":"0.03","id":77,"servise":"Wildberries","serviseImg":"bg-uu","number":"Numbers: 27220","value":"uu"},{"cost":"0.05","id":78,"servise":"BlaBlaCar","serviseImg":"bg-ua","number":"Numbers: 24367","value":"ua"},{"cost":"0.09","id":79,"servise":"Alibaba","serviseImg":"bg-ab","number":"Numbers: 17818","value":"ab"},{"cost":"0.00","id":80,"servise":"Inboxlv","serviseImg":"bg-iv","number":"Numbers: 0","value":"iv"},{"cost":"0.00","id":81,"servise":"Nttgame","serviseImg":"bg-zy","number":"Numbers: 0","value":"zy"},{"cost":"0.00","id":82,"servise":"Surveytime","serviseImg":"bg-gd","number":"Numbers: 0","value":"gd"},{"cost":"0.00","id":83,"servise":"Mylove","serviseImg":"bg-fy","number":"Numbers: 0","value":"fy"},{"cost":"0.02","id":84,"servise":"mosru","serviseImg":"bg-ce","number":"Numbers: 27173","value":"ce"},{"cost":"0.00","id":85,"servise":"Truecaller","serviseImg":"bg-tl","number":"Numbers: 0","value":"tl"},{"cost":"0.00","id":86,"servise":"Globus","serviseImg":"bg-hm","number":"Numbers: 0","value":"hm"},{"cost":"0.03","id":87,"servise":"Bolt","serviseImg":"bg-tx","number":"Numbers: 27378","value":"tx"},{"cost":"0.00","id":88,"servise":"Shopee","serviseImg":"bg-ka","number":"Numbers: 0","value":"ka"},{"cost":"0.03","id":89,"servise":"Perekrestok.ru","serviseImg":"bg-pl","number":"Numbers: 27883","value":"pl"},{"cost":"0.03","id":90,"servise":"Burger King","serviseImg":"bg-ip","number":"Numbers: 27764","value":"ip"},{"cost":"0.00","id":91,"servise":"Prom","serviseImg":"bg-cm","number":"Numbers: 0","value":"cm"},{"cost":"0.03","id":92,"servise":"AliPay","serviseImg":"bg-hw","number":"Numbers: 27166","value":"hw"},{"cost":"0.00","id":93,"servise":"Karusel","serviseImg":"bg-de","number":"Numbers: 0","value":"de"},{"cost":"0.00","id":94,"servise":"IVI","serviseImg":"bg-jc","number":"Numbers: 0","value":"jc"},{"cost":"0.03","id":95,"servise":"inDriver","serviseImg":"bg-rl","number":"Numbers: 27534","value":"rl"},{"cost":"0.03","id":96,"servise":"Happn","serviseImg":"bg-df","number":"Numbers: 27785","value":"df"},{"cost":"0.00","id":97,"servise":"RuTube","serviseImg":"bg-ui","number":"Numbers: 0","value":"ui"},{"cost":"0.03","id":98,"servise":"Magnolia","serviseImg":"bg-up","number":"Numbers: 27884","value":"up"},{"cost":"0.03","id":99,"servise":"Foodpanda","serviseImg":"bg-nz","number":"Numbers: 27493","value":"nz"},{"cost":"0.00","id":100,"servise":"Weibo","serviseImg":"bg-kf","number":"Numbers: 0","value":"kf"},{"cost":"0.00","id":101,"servise":"BillMill","serviseImg":"bg-ri","number":"Numbers: 0","value":"ri"},{"cost":"0.00","id":102,"servise":"Quipp","serviseImg":"bg-cc","number":"Numbers: 0","value":"cc"},{"cost":"0.00","id":103,"servise":"Okta","serviseImg":"bg-lr","number":"Numbers: 0","value":"lr"},{"cost":"0.03","id":104,"servise":"JDcom","serviseImg":"bg-za","number":"Numbers: 27891","value":"za"},{"cost":"0.05","id":105,"servise":"MTS CashBack","serviseImg":"bg-da","number":"Numbers: 12860","value":"da"},{"cost":"0.00","id":106,"servise":"Fiqsy","serviseImg":"bg-ug","number":"Numbers: 0","value":"ug"},{"cost":"0.00","id":107,"servise":"KuCoinPlay","serviseImg":"bg-sq","number":"Numbers: 0","value":"sq"},{"cost":"0.00","id":108,"servise":"Papara","serviseImg":"bg-zr","number":"Numbers: 0","value":"zr"},{"cost":"0.00","id":109,"servise":"Wish","serviseImg":"bg-xv","number":"Numbers: 0","value":"xv"},{"cost":"0.00","id":110,"servise":"Icrypex","serviseImg":"bg-cx","number":"Numbers: 0","value":"cx"},{"cost":"0.00","id":111,"servise":"PaddyPower","serviseImg":"bg-cw","number":"Numbers: 0","value":"cw"},{"cost":"0.05","id":112,"servise":"Baidu","serviseImg":"bg-li","number":"Numbers: 27813","value":"li"},{"cost":"0.00","id":113,"servise":"Dominos Pizza","serviseImg":"bg-dz","number":"Numbers: 0","value":"dz"},{"cost":"0.00","id":114,"servise":"paycell","serviseImg":"bg-xz","number":"Numbers: 0","value":"xz"},{"cost":"0.03","id":115,"servise":"Lenta","serviseImg":"bg-rd","number":"Numbers: 27651","value":"rd"},{"cost":"0.00","id":116,"servise":"Payberry","serviseImg":"bg-qb","number":"Numbers: 0","value":"qb"},{"cost":"0.03","id":117,"servise":"Drom","serviseImg":"bg-hz","number":"Numbers: 27673","value":"hz"},{"cost":"0.00","id":118,"servise":"GlobalTel","serviseImg":"bg-gl","number":"Numbers: 0","value":"gl"},{"cost":"0.00","id":119,"servise":"Deliveroo","serviseImg":"bg-zk","number":"Numbers: 0","value":"zk"},{"cost":"0.00","id":120,"servise":"Socios","serviseImg":"bg-ia","number":"Numbers: 0","value":"ia"},{"cost":"0.00","id":121,"servise":"Wmaraci","serviseImg":"bg-xl","number":"Numbers: 0","value":"xl"},{"cost":"0.00","id":122,"servise":"Yemeksepeti","serviseImg":"bg-yi","number":"Numbers: 0","value":"yi"},{"cost":"0.00","id":123,"servise":"Nike","serviseImg":"bg-ew","number":"Numbers: 0","value":"ew"},{"cost":"0.02","id":124,"servise":"myGLO","serviseImg":"bg-ae","number":"Numbers: 31671","value":"ae"},{"cost":"0.02","id":125,"servise":"YouStar","serviseImg":"bg-gb","number":"Numbers: 31133","value":"gb"},{"cost":"0.15","id":126,"servise":"\u0420\u0421\u0410","serviseImg":"bg-cy","number":"Numbers: 25178","value":"cy"},{"cost":"0.00","id":127,"servise":"RosaKhutor","serviseImg":"bg-qm","number":"Numbers: 0","value":"qm"},{"cost":"0.00","id":128,"servise":"eBay","serviseImg":"bg-dh","number":"Numbers: 0","value":"dh"},{"cost":"0.00","id":129,"servise":"Pay.kvartplata.ru+","serviseImg":"bg-yb","number":"Numbers: 0","value":"yb"},{"cost":"0.00","id":130,"servise":"GG","serviseImg":"bg-qe","number":"Numbers: 0","value":"qe"},{"cost":"0.03","id":131,"servise":"Grindr","serviseImg":"bg-yw","number":"Numbers: 4841","value":"yw"},{"cost":"0.00","id":132,"servise":"OffGamers","serviseImg":"bg-uz","number":"Numbers: 0","value":"uz"},{"cost":"0.00","id":133,"servise":"Hepsiburadacom","serviseImg":"bg-gx","number":"Numbers: 0","value":"gx"},{"cost":"0.00","id":134,"servise":"Coinbase","serviseImg":"bg-re","number":"Numbers: 0","value":"re"},{"cost":"0.00","id":135,"servise":"RADA NABU","serviseImg":"bg-tj","number":"Numbers: 0","value":"tj"},{"cost":"0.09","id":136,"servise":"PayPal","serviseImg":"bg-ts","number":"Numbers: 27144","value":"ts"},{"cost":"0.00","id":137,"servise":"hily","serviseImg":"bg-rt","number":"Numbers: 0","value":"rt"},{"cost":"0.00","id":138,"servise":"SneakersnStuff","serviseImg":"bg-sf","number":"Numbers: 0","value":"sf"},{"cost":"0.00","id":139,"servise":"Dostavista","serviseImg":"bg-sv","number":"Numbers: 0","value":"sv"},{"cost":"0.00","id":140,"servise":"32red","serviseImg":"bg-qi","number":"Numbers: 0","value":"qi"},{"cost":"0.02","id":141,"servise":"Blizzard","serviseImg":"bg-bz","number":"Numbers: 27797","value":"bz"},{"cost":"0.00","id":142,"servise":"ezbuy","serviseImg":"bg-db","number":"Numbers: 0","value":"db"},{"cost":"0.00","id":143,"servise":"CoinField","serviseImg":"bg-vw","number":"Numbers: 0","value":"vw"},{"cost":"0.00","id":144,"servise":"Airtel","serviseImg":"bg-zl","number":"Numbers: 0","value":"zl"},{"cost":"0.00","id":145,"servise":"Airtel","serviseImg":"bg-wf","number":"Numbers: 0","value":"wf"},{"cost":"0.00","id":146,"servise":"MrGreen","serviseImg":"bg-lw","number":"Numbers: 0","value":"lw"},{"cost":"0.00","id":147,"servise":"Rediffmail","serviseImg":"bg-co","number":"Numbers: 0","value":"co"},{"cost":"0.00","id":148,"servise":"miloan","serviseImg":"bg-ey","number":"Numbers: 0","value":"ey"},{"cost":"0.00","id":149,"servise":"Paytm","serviseImg":"bg-ge","number":"Numbers: 0","value":"ge"},{"cost":"0.00","id":150,"servise":"Dhani","serviseImg":"bg-os","number":"Numbers: 0","value":"os"},{"cost":"0.00","id":151,"servise":"CMTcuzdan","serviseImg":"bg-ql","number":"Numbers: 0","value":"ql"},{"cost":"0.00","id":152,"servise":"Mercado","serviseImg":"bg-cq","number":"Numbers: 0","value":"cq"},{"cost":"0.05","id":153,"servise":"DiDi","serviseImg":"bg-xk","number":"Numbers: 26447","value":"xk"},{"cost":"0.00","id":154,"servise":"Monese","serviseImg":"bg-py","number":"Numbers: 0","value":"py"},{"cost":"0.00","id":155,"servise":"Kotak811","serviseImg":"bg-rv","number":"Numbers: 0","value":"rv"},{"cost":"0.00","id":156,"servise":"Hopi","serviseImg":"bg-jl","number":"Numbers: 0","value":"jl"},{"cost":"0.00","id":157,"servise":"Trendyol","serviseImg":"bg-pr","number":"Numbers: 0","value":"pr"},{"cost":"0.00","id":158,"servise":"Justdating","serviseImg":"bg-pu","number":"Numbers: 0","value":"pu"},{"cost":"0.00","id":159,"servise":"Pairs","serviseImg":"bg-dk","number":"Numbers: 0","value":"dk"},{"cost":"0.00","id":160,"servise":"Touchance","serviseImg":"bg-fm","number":"Numbers: 0","value":"fm"},{"cost":"0.00","id":161,"servise":"SnappFood","serviseImg":"bg-ph","number":"Numbers: 0","value":"ph"},{"cost":"0.00","id":162,"servise":"NCsoft","serviseImg":"bg-sw","number":"Numbers: 0","value":"sw"},{"cost":"0.00","id":163,"servise":"Tosla","serviseImg":"bg-nr","number":"Numbers: 0","value":"nr"},{"cost":"0.00","id":164,"servise":"Ininal","serviseImg":"bg-hy","number":"Numbers: 0","value":"hy"},{"cost":"0.00","id":165,"servise":"Paysend","serviseImg":"bg-tr","number":"Numbers: 0","value":"tr"},{"cost":"0.00","id":166,"servise":"CDkeys","serviseImg":"bg-pq","number":"Numbers: 0","value":"pq"},{"cost":"0.00","id":167,"servise":"AVON","serviseImg":"bg-ff","number":"Numbers: 0","value":"ff"},{"cost":"0.03","id":168,"servise":"dodopizza","serviseImg":"bg-sd","number":"Numbers: 27739","value":"sd"},{"cost":"0.24","id":169,"servise":"McDonalds","serviseImg":"bg-ry","number":"Numbers: 7729","value":"ry"},{"cost":"0.00","id":170,"servise":"E bike Gewinnspiel","serviseImg":"bg-le","number":"Numbers: 0","value":"le"},{"cost":"0.00","id":171,"servise":"JKF","serviseImg":"bg-hr","number":"Numbers: 0","value":"hr"},{"cost":"0.00","id":172,"servise":"MyFishka","serviseImg":"bg-qa","number":"Numbers: 0","value":"qa"},{"cost":"0.00","id":173,"servise":"Craigslist","serviseImg":"bg-wc","number":"Numbers: 0","value":"wc"},{"cost":"0.00","id":174,"servise":"Foody","serviseImg":"bg-kw","number":"Numbers: 0","value":"kw"},{"cost":"0.00","id":175,"servise":"Grab","serviseImg":"bg-jg","number":"Numbers: 0","value":"jg"},{"cost":"0.05","id":176,"servise":"Zalo","serviseImg":"bg-mj","number":"Numbers: 28606","value":"mj"},{"cost":"0.00","id":177,"servise":"LiveScore","serviseImg":"bg-eu","number":"Numbers: 0","value":"eu"},{"cost":"0.00","id":178,"servise":"888casino","serviseImg":"bg-ll","number":"Numbers: 0","value":"ll"},{"cost":"0.00","id":179,"servise":"Gamer","serviseImg":"bg-ed","number":"Numbers: 0","value":"ed"},{"cost":"0.00","id":180,"servise":"Huya","serviseImg":"bg-pp","number":"Numbers: 0","value":"pp"},{"cost":"0.00","id":181,"servise":"WestStein","serviseImg":"bg-th","number":"Numbers: 0","value":"th"},{"cost":"0.04","id":182,"servise":"Tango","serviseImg":"bg-xr","number":"Numbers: 27765","value":"xr"},{"cost":"0.00","id":183,"servise":"Global24","serviseImg":"bg-iz","number":"Numbers: 0","value":"iz"},{"cost":"0.03","id":184,"servise":"\u041c\u0412\u0438\u0434\u0435\u043e","serviseImg":"bg-tk","number":"Numbers: 27660","value":"tk"},{"cost":"0.00","id":185,"servise":"Sheerid","serviseImg":"bg-rx","number":"Numbers: 0","value":"rx"},{"cost":"0.00","id":186,"servise":"99app","serviseImg":"bg-ki","number":"Numbers: 0","value":"ki"},{"cost":"0.00","id":187,"servise":"CAIXA","serviseImg":"bg-my","number":"Numbers: 0","value":"my"},{"cost":"0.00","id":188,"servise":"OfferUp","serviseImg":"bg-zm","number":"Numbers: 0","value":"zm"},{"cost":"0.00","id":189,"servise":"Swvl","serviseImg":"bg-tq","number":"Numbers: 0","value":"tq"},{"cost":"0.00","id":190,"servise":"Haraj","serviseImg":"bg-au","number":"Numbers: 0","value":"au"},{"cost":"0.00","id":191,"servise":"Taksheel","serviseImg":"bg-ei","number":"Numbers: 0","value":"ei"},{"cost":"0.00","id":192,"servise":"hamrahaval","serviseImg":"bg-rp","number":"Numbers: 0","value":"rp"},{"cost":"0.00","id":193,"servise":"Gamekit","serviseImg":"bg-pa","number":"Numbers: 0","value":"pa"},{"cost":"0.00","id":194,"servise":" \u015eikayet var","serviseImg":"bg-fs","number":"Numbers: 0","value":"fs"},{"cost":"0.00","id":195,"servise":"Getir","serviseImg":"bg-ul","number":"Numbers: 0","value":"ul"},{"cost":"0.00","id":196,"servise":"irancell","serviseImg":"bg-cf","number":"Numbers: 0","value":"cf"},{"cost":"0.00","id":197,"servise":"Alfa","serviseImg":"bg-bt","number":"Numbers: 0","value":"bt"},{"cost":"0.00","id":198,"servise":"Disney Hotstar","serviseImg":"bg-ud","number":"Numbers: 0","value":"ud"},{"cost":"0.00","id":199,"servise":"Agroinform","serviseImg":"bg-qu","number":"Numbers: 0","value":"qu"},{"cost":"0.00","id":200,"servise":"humblebundle","serviseImg":"bg-un","number":"Numbers: 0","value":"un"},{"cost":"0.00","id":201,"servise":"Faberlic","serviseImg":"bg-rm","number":"Numbers: 0","value":"rm"},{"cost":"0.00","id":202,"servise":"CafeBazaar","serviseImg":"bg-uo","number":"Numbers: 0","value":"uo"},{"cost":"0.00","id":203,"servise":"cryptocom","serviseImg":"bg-ti","number":"Numbers: 0","value":"ti"},{"cost":"0.00","id":204,"servise":"Gittigidiyor","serviseImg":"bg-nk","number":"Numbers: 0","value":"nk"},{"cost":"0.00","id":205,"servise":"mzadqatar","serviseImg":"bg-jm","number":"Numbers: 0","value":"jm"},{"cost":"0.00","id":206,"servise":"Algida","serviseImg":"bg-lp","number":"Numbers: 0","value":"lp"},{"cost":"0.00","id":207,"servise":"Cita Previa","serviseImg":"bg-si","number":"Numbers: 0","value":"si"},{"cost":"0.00","id":208,"servise":"Potato Chat","serviseImg":"bg-fj","number":"Numbers: 0","value":"fj"},{"cost":"0.00","id":209,"servise":"Bitaqaty","serviseImg":"bg-pt","number":"Numbers: 0","value":"pt"},{"cost":"0.00","id":210,"servise":"Primaries 2020","serviseImg":"bg-qc","number":"Numbers: 0","value":"qc"},{"cost":"0.00","id":211,"servise":"Amasia","serviseImg":"bg-yo","number":"Numbers: 0","value":"yo"},{"cost":"0.00","id":212,"servise":"Dream11","serviseImg":"bg-ve","number":"Numbers: 0","value":"ve"},{"cost":"0.00","id":213,"servise":"Oriflame","serviseImg":"bg-qh","number":"Numbers: 0","value":"qh"},{"cost":"0.00","id":214,"servise":"Bykea","serviseImg":"bg-iu","number":"Numbers: 0","value":"iu"},{"cost":"0.00","id":215,"servise":"Immowelt","serviseImg":"bg-ib","number":"Numbers: 0","value":"ib"},{"cost":"0.00","id":216,"servise":"Digikala","serviseImg":"bg-zv","number":"Numbers: 0","value":"zv"},{"cost":"0.00","id":217,"servise":"Wing Money","serviseImg":"bg-jb","number":"Numbers: 0","value":"jb"},{"cost":"0.00","id":218,"servise":"Yaay","serviseImg":"bg-vn","number":"Numbers: 0","value":"vn"},{"cost":"0.00","id":219,"servise":"GameArena","serviseImg":"bg-wn","number":"Numbers: 0","value":"wn"},{"cost":"0.04","id":220,"servise":"Vita express","serviseImg":"bg-bj","number":"Numbers: 27861","value":"bj"},{"cost":"0.00","id":221,"servise":"Auchan","serviseImg":"bg-st","number":"Numbers: 0","value":"st"},{"cost":"0.00","id":222,"servise":"Picpay","serviseImg":"bg-ev","number":"Numbers: 0","value":"ev"},{"cost":"0.00","id":223,"servise":"Blued","serviseImg":"bg-qn","number":"Numbers: 0","value":"qn"},{"cost":"0.05","id":224,"servise":"Not on the list","serviseImg":"bg-ot","number":"Numbers: 19352","value":"ot"}]
The problem is that after my knowledge this is a wrong formatted json file, even if I remove "[" and "]".
I though of just looking at it as a text file to get a specific value but I was unable to find something on the internet about this topic.
I want to get the following value:
From:
{"cost":"0.00","id":123,"servise":"Nike","serviseImg":"bg-ew","number":"Numbers: 0","value":"ew"}
I want to get:
Numbers: 0
Use json.loads to become a dictionary query:
import requests
import json
response = requests.get('https://sms-service-online.com/api/getServicesAndCost/?country=0&operator=any&lang=en')
data = response.json()
plain = data["data"]
for d in json.loads(plain):
if d['id'] == 123:
print(d)
You have a list of dict in your first example. So first you need to select which dict you want. For instance, if your query is called 'json_list'
json_list[2]
will get you the third item in that list.
For what you are asking, try:
j = {"cost":"0.00","id":123,"servise":"Nike","serviseImg":"bg-ew","number":"Numbers: 0","value":"ew"}
j["number"].split()[-1]
Assuming you want to check all numbers in all dict, try:
json_list=[{"cost":"0.45","id":0,"servise":"VK.com","serviseImg":"bg-vk","number":"Numbers: 3047","value":"vk"},{"cost":"0.07","id":1,"servise":"OK.ru","serviseImg":"bg-ok","number":"Numbers: 14397","value":"ok"},{"cost":"0.15","id":2,"servise":"Whatsapp","serviseImg":"bg-wa","number":"Numbers: 17610","value":"wa"},{"cost":"0.18","id":3,"servise":"Viber","serviseImg":"bg-vi","number":"Numbers: 413","value":"vi"},{"cost":"0.00","id":4,"servise":"Telegram","serviseImg":"bg-tg","number":"Numbers: 0","value":"tg"},{"cost":"0.30","id":5,"servise":"WeChat","serviseImg":"bg-wb","number":"Numbers: 28389","value":"wb"},{"cost":"0.15","id":6,"servise":"Google,youtube,Gmail","serviseImg":"bg-go","number":"Numbers: 15419","value":"go"},{"cost":"0.11","id":7,"servise":"avito","serviseImg":"bg-av","number":"Numbers: 17379","value":"av"},{"cost":"0.07","id":8,"servise":"facebook","serviseImg":"bg-fb","number":"Numbers: 21636","value":"fb"},{"cost":"0.03","id":9,"servise":"Twitter","serviseImg":"bg-tw","number":"Numbers: 26864","value":"tw"},{"cost":"0.05","id":10,"servise":"Uber","serviseImg":"bg-ub","number":"Numbers: 20975","value":"ub"},{"cost":"0.22","id":11,"servise":"Qiwi","serviseImg":"bg-qw","number":"Numbers: 20371","value":"qw"},{"cost":"0.02","id":12,"servise":"Gett","serviseImg":"bg-gt","number":"Numbers: 28501","value":"gt"},{"cost":"0.00","id":13,"servise":"OLX","serviseImg":"bg-sn","number":"Numbers: 0","value":"sn"},{"cost":"0.14","id":14,"servise":"Instagram","serviseImg":"bg-ig","number":"Numbers: 3799","value":"ig"},{"cost":"0.00","id":15,"servise":"Hezzl","serviseImg":"bg-ss","number":"Numbers: 0","value":"ss"},{"cost":"0.07","id":16,"servise":"\u042e\u043b\u0430","serviseImg":"bg-ym","number":"Numbers: 17597","value":"ym"},{"cost":"0.03","id":17,"servise":"Mail.ru","serviseImg":"bg-ma","number":"Numbers: 17936","value":"ma"},{"cost":"0.03","id":18,"servise":"Microsoft","serviseImg":"bg-mm","number":"Numbers: 3830","value":"mm"},{"cost":"0.03","id":19,"servise":"Airbnb","serviseImg":"bg-uk","number":"Numbers: 28266","value":"uk"},{"cost":"0.00","id":20,"servise":"Line messenger","serviseImg":"bg-me","number":"Numbers: 0","value":"me"},{"cost":"0.03","id":21,"servise":"Yahoo","serviseImg":"bg-mb","number":"Numbers: 19077","value":"mb"},{"cost":"0.00","id":22,"servise":"Drugvokrug.ru","serviseImg":"bg-we","number":"Numbers: 0","value":"we"},{"cost":"0.05","id":23,"servise":"5ka.ru","serviseImg":"bg-bd","number":"Numbers: 27541","value":"bd"},{"cost":"0.00","id":24,"servise":"HQ Trivia","serviseImg":"bg-kp","number":"Numbers: 0","value":"kp"},{"cost":"0.65","id":25,"servise":"Delivery Club","serviseImg":"bg-dt","number":"Numbers: 26812","value":"dt"},{"cost":"0.03","id":26,"servise":"Yandex","serviseImg":"bg-ya","number":"Numbers: 20944","value":"ya"},{"cost":"0.05","id":27,"servise":"Steam","serviseImg":"bg-mt","number":"Numbers: 28121","value":"mt"},{"cost":"0.04","id":28,"servise":"Tinder","serviseImg":"bg-oi","number":"Numbers: 27478","value":"oi"},{"cost":"0.02","id":29,"servise":"Mamba, MeetMe","serviseImg":"bg-fd","number":"Numbers: 25328","value":"fd"},{"cost":"0.00","id":30,"servise":"Dent","serviseImg":"bg-zz","number":"Numbers: 0","value":"zz"},{"cost":"0.07","id":31,"servise":"KakaoTalk","serviseImg":"bg-kt","number":"Numbers: 27823","value":"kt"},{"cost":"0.04","id":32,"servise":"AOL","serviseImg":"bg-pm","number":"Numbers: 23369","value":"pm"},{"cost":"0.02","id":33,"servise":"LinkedIN","serviseImg":"bg-tn","number":"Numbers: 32192","value":"tn"},{"cost":"0.03","id":34,"servise":"Tencent QQ","serviseImg":"bg-qq","number":"Numbers: 27883","value":"qq"},{"cost":"0.06","id":35,"servise":"Magnit","serviseImg":"bg-mg","number":"Numbers: 993","value":"mg"},{"cost":"0.00","id":36,"servise":"pof.com","serviseImg":"bg-pf","number":"Numbers: 0","value":"pf"},{"cost":"0.03","id":37,"servise":"Yalla","serviseImg":"bg-yl","number":"Numbers: 27822","value":"yl"},{"cost":"0.00","id":38,"servise":"kolesa.kz","serviseImg":"bg-kl","number":"Numbers: 0","value":"kl"},{"cost":"0.03","id":39,"servise":"premium.one","serviseImg":"bg-po","number":"Numbers: 25869","value":"po"},{"cost":"0.07","id":40,"servise":"Naver","serviseImg":"bg-nv","number":"Numbers: 27582","value":"nv"},{"cost":"0.03","id":41,"servise":"Netflix","serviseImg":"bg-nf","number":"Numbers: 27715","value":"nf"},{"cost":"0.00","id":42,"servise":"icq","serviseImg":"bg-iq","number":"Numbers: 0","value":"iq"},{"cost":"0.00","id":43,"servise":"Onlinerby","serviseImg":"bg-ob","number":"Numbers: 0","value":"ob"},{"cost":"0.00","id":44,"servise":"kufarby","serviseImg":"bg-kb","number":"Numbers: 0","value":"kb"},{"cost":"0.03","id":45,"servise":"Imo","serviseImg":"bg-im","number":"Numbers: 25198","value":"im"},{"cost":"0.00","id":46,"servise":"Michat","serviseImg":"bg-mc","number":"Numbers: 0","value":"mc"},{"cost":"0.03","id":47,"servise":"Discord","serviseImg":"bg-ds","number":"Numbers: 22011","value":"ds"},{"cost":"0.00","id":48,"servise":"Seosprint","serviseImg":"bg-vv","number":"Numbers: 0","value":"vv"},{"cost":"0.00","id":49,"servise":"Monobank","serviseImg":"bg-ji","number":"Numbers: 0","value":"ji"},{"cost":"0.03","id":50,"servise":"TikTok\/Douyin","serviseImg":"bg-lf","number":"Numbers: 26299","value":"lf"},{"cost":"0.00","id":51,"servise":"Ukrnet","serviseImg":"bg-hu","number":"Numbers: 0","value":"hu"},{"cost":"0.00","id":52,"servise":"Skout","serviseImg":"bg-wg","number":"Numbers: 0","value":"wg"},{"cost":"0.00","id":53,"servise":"EasyPay","serviseImg":"bg-rz","number":"Numbers: 0","value":"rz"},{"cost":"0.00","id":54,"servise":"Q12 Trivia","serviseImg":"bg-vf","number":"Numbers: 0","value":"vf"},{"cost":"0.00","id":55,"servise":"Pyro Music","serviseImg":"bg-ny","number":"Numbers: 0","value":"ny"},{"cost":"0.00","id":56,"servise":"Wolt","serviseImg":"bg-rr","number":"Numbers: 0","value":"rr"},{"cost":"0.00","id":57,"servise":"CliQQ","serviseImg":"bg-fe","number":"Numbers: 0","value":"fe"},{"cost":"0.00","id":58,"servise":"ssoidnet","serviseImg":"bg-la","number":"Numbers: 0","value":"la"},{"cost":"0.00","id":59,"servise":"Zoho","serviseImg":"bg-zh","number":"Numbers: 0","value":"zh"},{"cost":"0.00","id":60,"servise":"Ticketmaster","serviseImg":"bg-gp","number":"Numbers: 0","value":"gp"},{"cost":"0.05","id":61,"servise":"Amazon","serviseImg":"bg-am","number":"Numbers: 25313","value":"am"},{"cost":"0.00","id":62,"servise":"Olacabs","serviseImg":"bg-ly","number":"Numbers: 0","value":"ly"},{"cost":"0.00","id":63,"servise":"Rambler","serviseImg":"bg-tc","number":"Numbers: 0","value":"tc"},{"cost":"0.02","id":64,"servise":"ProtonMail","serviseImg":"bg-dp","number":"Numbers: 30668","value":"dp"},{"cost":"0.00","id":65,"servise":"NRJ Music Awards","serviseImg":"bg-pg","number":"Numbers: 0","value":"pg"},{"cost":"0.03","id":66,"servise":"Citymobil","serviseImg":"bg-yf","number":"Numbers: 26997","value":"yf"},{"cost":"0.00","id":67,"servise":"MIRATORG","serviseImg":"bg-op","number":"Numbers: 0","value":"op"},{"cost":"0.03","id":68,"servise":"PGbonus","serviseImg":"bg-fx","number":"Numbers: 27563","value":"fx"},{"cost":"0.03","id":69,"servise":"MEGA","serviseImg":"bg-qr","number":"Numbers: 27848","value":"qr"},{"cost":"0.03","id":70,"servise":"SportMaster","serviseImg":"bg-yk","number":"Numbers: 26584","value":"yk"},{"cost":"0.03","id":71,"servise":"Careem","serviseImg":"bg-ls","number":"Numbers: 27873","value":"ls"},{"cost":"0.03","id":72,"servise":"BIGO LIVE","serviseImg":"bg-bl","number":"Numbers: 25421","value":"bl"},{"cost":"0.03","id":73,"servise":"MyMusicTaste","serviseImg":"bg-mu","number":"Numbers: 27898","value":"mu"},{"cost":"0.03","id":74,"servise":"Snapchat","serviseImg":"bg-fu","number":"Numbers: 27758","value":"fu"},{"cost":"0.00","id":75,"servise":"Keybase","serviseImg":"bg-bf","number":"Numbers: 0","value":"bf"},{"cost":"0.03","id":76,"servise":"OZON","serviseImg":"bg-sg","number":"Numbers: 26595","value":"sg"},{"cost":"0.03","id":77,"servise":"Wildberries","serviseImg":"bg-uu","number":"Numbers: 27220","value":"uu"},{"cost":"0.05","id":78,"servise":"BlaBlaCar","serviseImg":"bg-ua","number":"Numbers: 24367","value":"ua"},{"cost":"0.09","id":79,"servise":"Alibaba","serviseImg":"bg-ab","number":"Numbers: 17818","value":"ab"},{"cost":"0.00","id":80,"servise":"Inboxlv","serviseImg":"bg-iv","number":"Numbers: 0","value":"iv"},{"cost":"0.00","id":81,"servise":"Nttgame","serviseImg":"bg-zy","number":"Numbers: 0","value":"zy"},{"cost":"0.00","id":82,"servise":"Surveytime","serviseImg":"bg-gd","number":"Numbers: 0","value":"gd"},{"cost":"0.00","id":83,"servise":"Mylove","serviseImg":"bg-fy","number":"Numbers: 0","value":"fy"},{"cost":"0.02","id":84,"servise":"mosru","serviseImg":"bg-ce","number":"Numbers: 27173","value":"ce"},{"cost":"0.00","id":85,"servise":"Truecaller","serviseImg":"bg-tl","number":"Numbers: 0","value":"tl"},{"cost":"0.00","id":86,"servise":"Globus","serviseImg":"bg-hm","number":"Numbers: 0","value":"hm"},{"cost":"0.03","id":87,"servise":"Bolt","serviseImg":"bg-tx","number":"Numbers: 27378","value":"tx"},{"cost":"0.00","id":88,"servise":"Shopee","serviseImg":"bg-ka","number":"Numbers: 0","value":"ka"},{"cost":"0.03","id":89,"servise":"Perekrestok.ru","serviseImg":"bg-pl","number":"Numbers: 27883","value":"pl"},{"cost":"0.03","id":90,"servise":"Burger King","serviseImg":"bg-ip","number":"Numbers: 27764","value":"ip"},{"cost":"0.00","id":91,"servise":"Prom","serviseImg":"bg-cm","number":"Numbers: 0","value":"cm"},{"cost":"0.03","id":92,"servise":"AliPay","serviseImg":"bg-hw","number":"Numbers: 27166","value":"hw"},{"cost":"0.00","id":93,"servise":"Karusel","serviseImg":"bg-de","number":"Numbers: 0","value":"de"},{"cost":"0.00","id":94,"servise":"IVI","serviseImg":"bg-jc","number":"Numbers: 0","value":"jc"},{"cost":"0.03","id":95,"servise":"inDriver","serviseImg":"bg-rl","number":"Numbers: 27534","value":"rl"},{"cost":"0.03","id":96,"servise":"Happn","serviseImg":"bg-df","number":"Numbers: 27785","value":"df"},{"cost":"0.00","id":97,"servise":"RuTube","serviseImg":"bg-ui","number":"Numbers: 0","value":"ui"},{"cost":"0.03","id":98,"servise":"Magnolia","serviseImg":"bg-up","number":"Numbers: 27884","value":"up"},{"cost":"0.03","id":99,"servise":"Foodpanda","serviseImg":"bg-nz","number":"Numbers: 27493","value":"nz"},{"cost":"0.00","id":100,"servise":"Weibo","serviseImg":"bg-kf","number":"Numbers: 0","value":"kf"},{"cost":"0.00","id":101,"servise":"BillMill","serviseImg":"bg-ri","number":"Numbers: 0","value":"ri"},{"cost":"0.00","id":102,"servise":"Quipp","serviseImg":"bg-cc","number":"Numbers: 0","value":"cc"},{"cost":"0.00","id":103,"servise":"Okta","serviseImg":"bg-lr","number":"Numbers: 0","value":"lr"},{"cost":"0.03","id":104,"servise":"JDcom","serviseImg":"bg-za","number":"Numbers: 27891","value":"za"},{"cost":"0.05","id":105,"servise":"MTS CashBack","serviseImg":"bg-da","number":"Numbers: 12860","value":"da"},{"cost":"0.00","id":106,"servise":"Fiqsy","serviseImg":"bg-ug","number":"Numbers: 0","value":"ug"},{"cost":"0.00","id":107,"servise":"KuCoinPlay","serviseImg":"bg-sq","number":"Numbers: 0","value":"sq"},{"cost":"0.00","id":108,"servise":"Papara","serviseImg":"bg-zr","number":"Numbers: 0","value":"zr"},{"cost":"0.00","id":109,"servise":"Wish","serviseImg":"bg-xv","number":"Numbers: 0","value":"xv"},{"cost":"0.00","id":110,"servise":"Icrypex","serviseImg":"bg-cx","number":"Numbers: 0","value":"cx"},{"cost":"0.00","id":111,"servise":"PaddyPower","serviseImg":"bg-cw","number":"Numbers: 0","value":"cw"},{"cost":"0.05","id":112,"servise":"Baidu","serviseImg":"bg-li","number":"Numbers: 27813","value":"li"},{"cost":"0.00","id":113,"servise":"Dominos Pizza","serviseImg":"bg-dz","number":"Numbers: 0","value":"dz"},{"cost":"0.00","id":114,"servise":"paycell","serviseImg":"bg-xz","number":"Numbers: 0","value":"xz"},{"cost":"0.03","id":115,"servise":"Lenta","serviseImg":"bg-rd","number":"Numbers: 27651","value":"rd"},{"cost":"0.00","id":116,"servise":"Payberry","serviseImg":"bg-qb","number":"Numbers: 0","value":"qb"},{"cost":"0.03","id":117,"servise":"Drom","serviseImg":"bg-hz","number":"Numbers: 27673","value":"hz"},{"cost":"0.00","id":118,"servise":"GlobalTel","serviseImg":"bg-gl","number":"Numbers: 0","value":"gl"},{"cost":"0.00","id":119,"servise":"Deliveroo","serviseImg":"bg-zk","number":"Numbers: 0","value":"zk"},{"cost":"0.00","id":120,"servise":"Socios","serviseImg":"bg-ia","number":"Numbers: 0","value":"ia"},{"cost":"0.00","id":121,"servise":"Wmaraci","serviseImg":"bg-xl","number":"Numbers: 0","value":"xl"},{"cost":"0.00","id":122,"servise":"Yemeksepeti","serviseImg":"bg-yi","number":"Numbers: 0","value":"yi"},{"cost":"0.00","id":123,"servise":"Nike","serviseImg":"bg-ew","number":"Numbers: 0","value":"ew"},{"cost":"0.02","id":124,"servise":"myGLO","serviseImg":"bg-ae","number":"Numbers: 31671","value":"ae"},{"cost":"0.02","id":125,"servise":"YouStar","serviseImg":"bg-gb","number":"Numbers: 31133","value":"gb"},{"cost":"0.15","id":126,"servise":"\u0420\u0421\u0410","serviseImg":"bg-cy","number":"Numbers: 25178","value":"cy"},{"cost":"0.00","id":127,"servise":"RosaKhutor","serviseImg":"bg-qm","number":"Numbers: 0","value":"qm"},{"cost":"0.00","id":128,"servise":"eBay","serviseImg":"bg-dh","number":"Numbers: 0","value":"dh"},{"cost":"0.00","id":129,"servise":"Pay.kvartplata.ru+","serviseImg":"bg-yb","number":"Numbers: 0","value":"yb"},{"cost":"0.00","id":130,"servise":"GG","serviseImg":"bg-qe","number":"Numbers: 0","value":"qe"},{"cost":"0.03","id":131,"servise":"Grindr","serviseImg":"bg-yw","number":"Numbers: 4841","value":"yw"},{"cost":"0.00","id":132,"servise":"OffGamers","serviseImg":"bg-uz","number":"Numbers: 0","value":"uz"},{"cost":"0.00","id":133,"servise":"Hepsiburadacom","serviseImg":"bg-gx","number":"Numbers: 0","value":"gx"},{"cost":"0.00","id":134,"servise":"Coinbase","serviseImg":"bg-re","number":"Numbers: 0","value":"re"},{"cost":"0.00","id":135,"servise":"RADA NABU","serviseImg":"bg-tj","number":"Numbers: 0","value":"tj"},{"cost":"0.09","id":136,"servise":"PayPal","serviseImg":"bg-ts","number":"Numbers: 27144","value":"ts"},{"cost":"0.00","id":137,"servise":"hily","serviseImg":"bg-rt","number":"Numbers: 0","value":"rt"},{"cost":"0.00","id":138,"servise":"SneakersnStuff","serviseImg":"bg-sf","number":"Numbers: 0","value":"sf"},{"cost":"0.00","id":139,"servise":"Dostavista","serviseImg":"bg-sv","number":"Numbers: 0","value":"sv"},{"cost":"0.00","id":140,"servise":"32red","serviseImg":"bg-qi","number":"Numbers: 0","value":"qi"},{"cost":"0.02","id":141,"servise":"Blizzard","serviseImg":"bg-bz","number":"Numbers: 27797","value":"bz"},{"cost":"0.00","id":142,"servise":"ezbuy","serviseImg":"bg-db","number":"Numbers: 0","value":"db"},{"cost":"0.00","id":143,"servise":"CoinField","serviseImg":"bg-vw","number":"Numbers: 0","value":"vw"},{"cost":"0.00","id":144,"servise":"Airtel","serviseImg":"bg-zl","number":"Numbers: 0","value":"zl"},{"cost":"0.00","id":145,"servise":"Airtel","serviseImg":"bg-wf","number":"Numbers: 0","value":"wf"},{"cost":"0.00","id":146,"servise":"MrGreen","serviseImg":"bg-lw","number":"Numbers: 0","value":"lw"},{"cost":"0.00","id":147,"servise":"Rediffmail","serviseImg":"bg-co","number":"Numbers: 0","value":"co"},{"cost":"0.00","id":148,"servise":"miloan","serviseImg":"bg-ey","number":"Numbers: 0","value":"ey"},{"cost":"0.00","id":149,"servise":"Paytm","serviseImg":"bg-ge","number":"Numbers: 0","value":"ge"},{"cost":"0.00","id":150,"servise":"Dhani","serviseImg":"bg-os","number":"Numbers: 0","value":"os"},{"cost":"0.00","id":151,"servise":"CMTcuzdan","serviseImg":"bg-ql","number":"Numbers: 0","value":"ql"},{"cost":"0.00","id":152,"servise":"Mercado","serviseImg":"bg-cq","number":"Numbers: 0","value":"cq"},{"cost":"0.05","id":153,"servise":"DiDi","serviseImg":"bg-xk","number":"Numbers: 26447","value":"xk"},{"cost":"0.00","id":154,"servise":"Monese","serviseImg":"bg-py","number":"Numbers: 0","value":"py"},{"cost":"0.00","id":155,"servise":"Kotak811","serviseImg":"bg-rv","number":"Numbers: 0","value":"rv"},{"cost":"0.00","id":156,"servise":"Hopi","serviseImg":"bg-jl","number":"Numbers: 0","value":"jl"},{"cost":"0.00","id":157,"servise":"Trendyol","serviseImg":"bg-pr","number":"Numbers: 0","value":"pr"},{"cost":"0.00","id":158,"servise":"Justdating","serviseImg":"bg-pu","number":"Numbers: 0","value":"pu"},{"cost":"0.00","id":159,"servise":"Pairs","serviseImg":"bg-dk","number":"Numbers: 0","value":"dk"},{"cost":"0.00","id":160,"servise":"Touchance","serviseImg":"bg-fm","number":"Numbers: 0","value":"fm"},{"cost":"0.00","id":161,"servise":"SnappFood","serviseImg":"bg-ph","number":"Numbers: 0","value":"ph"},{"cost":"0.00","id":162,"servise":"NCsoft","serviseImg":"bg-sw","number":"Numbers: 0","value":"sw"},{"cost":"0.00","id":163,"servise":"Tosla","serviseImg":"bg-nr","number":"Numbers: 0","value":"nr"},{"cost":"0.00","id":164,"servise":"Ininal","serviseImg":"bg-hy","number":"Numbers: 0","value":"hy"},{"cost":"0.00","id":165,"servise":"Paysend","serviseImg":"bg-tr","number":"Numbers: 0","value":"tr"},{"cost":"0.00","id":166,"servise":"CDkeys","serviseImg":"bg-pq","number":"Numbers: 0","value":"pq"},{"cost":"0.00","id":167,"servise":"AVON","serviseImg":"bg-ff","number":"Numbers: 0","value":"ff"},{"cost":"0.03","id":168,"servise":"dodopizza","serviseImg":"bg-sd","number":"Numbers: 27739","value":"sd"},{"cost":"0.24","id":169,"servise":"McDonalds","serviseImg":"bg-ry","number":"Numbers: 7729","value":"ry"},{"cost":"0.00","id":170,"servise":"E bike Gewinnspiel","serviseImg":"bg-le","number":"Numbers: 0","value":"le"},{"cost":"0.00","id":171,"servise":"JKF","serviseImg":"bg-hr","number":"Numbers: 0","value":"hr"},{"cost":"0.00","id":172,"servise":"MyFishka","serviseImg":"bg-qa","number":"Numbers: 0","value":"qa"},{"cost":"0.00","id":173,"servise":"Craigslist","serviseImg":"bg-wc","number":"Numbers: 0","value":"wc"},{"cost":"0.00","id":174,"servise":"Foody","serviseImg":"bg-kw","number":"Numbers: 0","value":"kw"},{"cost":"0.00","id":175,"servise":"Grab","serviseImg":"bg-jg","number":"Numbers: 0","value":"jg"},{"cost":"0.05","id":176,"servise":"Zalo","serviseImg":"bg-mj","number":"Numbers: 28606","value":"mj"},{"cost":"0.00","id":177,"servise":"LiveScore","serviseImg":"bg-eu","number":"Numbers: 0","value":"eu"},{"cost":"0.00","id":178,"servise":"888casino","serviseImg":"bg-ll","number":"Numbers: 0","value":"ll"},{"cost":"0.00","id":179,"servise":"Gamer","serviseImg":"bg-ed","number":"Numbers: 0","value":"ed"},{"cost":"0.00","id":180,"servise":"Huya","serviseImg":"bg-pp","number":"Numbers: 0","value":"pp"},{"cost":"0.00","id":181,"servise":"WestStein","serviseImg":"bg-th","number":"Numbers: 0","value":"th"},{"cost":"0.04","id":182,"servise":"Tango","serviseImg":"bg-xr","number":"Numbers: 27765","value":"xr"},{"cost":"0.00","id":183,"servise":"Global24","serviseImg":"bg-iz","number":"Numbers: 0","value":"iz"},{"cost":"0.03","id":184,"servise":"\u041c\u0412\u0438\u0434\u0435\u043e","serviseImg":"bg-tk","number":"Numbers: 27660","value":"tk"},{"cost":"0.00","id":185,"servise":"Sheerid","serviseImg":"bg-rx","number":"Numbers: 0","value":"rx"},{"cost":"0.00","id":186,"servise":"99app","serviseImg":"bg-ki","number":"Numbers: 0","value":"ki"},{"cost":"0.00","id":187,"servise":"CAIXA","serviseImg":"bg-my","number":"Numbers: 0","value":"my"},{"cost":"0.00","id":188,"servise":"OfferUp","serviseImg":"bg-zm","number":"Numbers: 0","value":"zm"},{"cost":"0.00","id":189,"servise":"Swvl","serviseImg":"bg-tq","number":"Numbers: 0","value":"tq"},{"cost":"0.00","id":190,"servise":"Haraj","serviseImg":"bg-au","number":"Numbers: 0","value":"au"},{"cost":"0.00","id":191,"servise":"Taksheel","serviseImg":"bg-ei","number":"Numbers: 0","value":"ei"},{"cost":"0.00","id":192,"servise":"hamrahaval","serviseImg":"bg-rp","number":"Numbers: 0","value":"rp"},{"cost":"0.00","id":193,"servise":"Gamekit","serviseImg":"bg-pa","number":"Numbers: 0","value":"pa"},{"cost":"0.00","id":194,"servise":" \u015eikayet var","serviseImg":"bg-fs","number":"Numbers: 0","value":"fs"},{"cost":"0.00","id":195,"servise":"Getir","serviseImg":"bg-ul","number":"Numbers: 0","value":"ul"},{"cost":"0.00","id":196,"servise":"irancell","serviseImg":"bg-cf","number":"Numbers: 0","value":"cf"},{"cost":"0.00","id":197,"servise":"Alfa","serviseImg":"bg-bt","number":"Numbers: 0","value":"bt"},{"cost":"0.00","id":198,"servise":"Disney Hotstar","serviseImg":"bg-ud","number":"Numbers: 0","value":"ud"},{"cost":"0.00","id":199,"servise":"Agroinform","serviseImg":"bg-qu","number":"Numbers: 0","value":"qu"},{"cost":"0.00","id":200,"servise":"humblebundle","serviseImg":"bg-un","number":"Numbers: 0","value":"un"},{"cost":"0.00","id":201,"servise":"Faberlic","serviseImg":"bg-rm","number":"Numbers: 0","value":"rm"},{"cost":"0.00","id":202,"servise":"CafeBazaar","serviseImg":"bg-uo","number":"Numbers: 0","value":"uo"},{"cost":"0.00","id":203,"servise":"cryptocom","serviseImg":"bg-ti","number":"Numbers: 0","value":"ti"},{"cost":"0.00","id":204,"servise":"Gittigidiyor","serviseImg":"bg-nk","number":"Numbers: 0","value":"nk"},{"cost":"0.00","id":205,"servise":"mzadqatar","serviseImg":"bg-jm","number":"Numbers: 0","value":"jm"},{"cost":"0.00","id":206,"servise":"Algida","serviseImg":"bg-lp","number":"Numbers: 0","value":"lp"},{"cost":"0.00","id":207,"servise":"Cita Previa","serviseImg":"bg-si","number":"Numbers: 0","value":"si"},{"cost":"0.00","id":208,"servise":"Potato Chat","serviseImg":"bg-fj","number":"Numbers: 0","value":"fj"},{"cost":"0.00","id":209,"servise":"Bitaqaty","serviseImg":"bg-pt","number":"Numbers: 0","value":"pt"},{"cost":"0.00","id":210,"servise":"Primaries 2020","serviseImg":"bg-qc","number":"Numbers: 0","value":"qc"},{"cost":"0.00","id":211,"servise":"Amasia","serviseImg":"bg-yo","number":"Numbers: 0","value":"yo"},{"cost":"0.00","id":212,"servise":"Dream11","serviseImg":"bg-ve","number":"Numbers: 0","value":"ve"},{"cost":"0.00","id":213,"servise":"Oriflame","serviseImg":"bg-qh","number":"Numbers: 0","value":"qh"},{"cost":"0.00","id":214,"servise":"Bykea","serviseImg":"bg-iu","number":"Numbers: 0","value":"iu"},{"cost":"0.00","id":215,"servise":"Immowelt","serviseImg":"bg-ib","number":"Numbers: 0","value":"ib"},{"cost":"0.00","id":216,"servise":"Digikala","serviseImg":"bg-zv","number":"Numbers: 0","value":"zv"},{"cost":"0.00","id":217,"servise":"Wing Money","serviseImg":"bg-jb","number":"Numbers: 0","value":"jb"},{"cost":"0.00","id":218,"servise":"Yaay","serviseImg":"bg-vn","number":"Numbers: 0","value":"vn"},{"cost":"0.00","id":219,"servise":"GameArena","serviseImg":"bg-wn","number":"Numbers: 0","value":"wn"},{"cost":"0.04","id":220,"servise":"Vita express","serviseImg":"bg-bj","number":"Numbers: 27861","value":"bj"},{"cost":"0.00","id":221,"servise":"Auchan","serviseImg":"bg-st","number":"Numbers: 0","value":"st"},{"cost":"0.00","id":222,"servise":"Picpay","serviseImg":"bg-ev","number":"Numbers: 0","value":"ev"},{"cost":"0.00","id":223,"servise":"Blued","serviseImg":"bg-qn","number":"Numbers: 0","value":"qn"},{"cost":"0.05","id":224,"servise":"Not on the list","serviseImg":"bg-ot","number":"Numbers: 19352","value":"ot"}]
for j in json_list:
n = i['number'].split()[-1]
print(n)
# do something interesting with n

Output not displaying full list of elements appended

from csv import reader
def func(sku_list):
values = []
with open(sku_list, 'r', encoding = 'utf-8') as pr:
rows = reader(pr)
for sku in rows:
values.append(sku[1])
return(values)
if __name__ == '__main__':
dir_path = "C:/Users/XXXX/Downloads/"
vendors = dir_path + 'file.csv'
new_prices = func(vendors)
print(new_prices)
sku_list is a csv file filled with pairs of brand names and their skus that I have downloaded from my db, for some reason as it iters through the rows and grabs just the sku value, hence sku[1], it stops well short of the actual length I expect the list to be
sku_list is 85,892 tuples long but when I print out the values appended to the list values it simply returns this:
['SKU', 'MWGB4896', 'MWGB4872', 'MWGB4848', 'MWGB3648', 'WGB4896', 'WGB4872', 'WGB4848', 'WGB3648', 'WGB2436', 'WGB1824', 'BKGB4896NT', 'BKGB4872NT', 'BKGB4848NT', 'BKGB3648NT', 'BKGB2436NT', 'BKGB1824NT', 'WFC2418G', 'WFC2418', 'WFC3624', 'WFC2418LB', 'WFC3648LB', 'WFC3624LB', 'WFC3624G', 'WFC3648G', 'WFC3648', 'LOWFC3624LB', 'LOWFC3624G', 'LOWFC3624', 'LOWFC2418LB', 'LOWFC2418G', 'LOWFC2418', 'LOWFC3648LB', 'LOWFC3648', 'LOWFC3648G', 'WM-7-B', 'WM-7-G', 'WM-7-BK', 'WMC-7', 'WM-7-R', 'APS-50', 'APS-70', 'APS-60', 'APS-84', 'SS15W', 'SC15W', 'SB15W', 'MFL-2W', 'WP-48', 'WP-40', 'WP-36', 'MP-48', 'MP-40', 'MP-36', 'OP-40', 'OP-36', 'OP-48', 'FFVSU96-2', 'FFVSU144-2', 'FFVSU192-2', '1-WA-1B', '1-WA-1BP', 'WCS-12', 'WCS-144', 'OPLD3416LSPP-2', 'OPLD3416LSPP-4', 'OPLD3416LSPP-5', 'OPLD3416LSPP-7', 'OPLD3416LSPP-8', 'OPLD1818LSPP-2', 'OPLD1818LSPP-4', 'OPLD1818LSPP-5', 'OPLD1818LSPP-7', 'OPLD1818LSPP-8', 'OPLD1818L-2', 'OPLD1818L-5', 'OPLD1818L-4', 'OPLD3416L-2', 'OPLD3416L-4', 'OPLD3416L-5', 'OPLD3416L-7', 'OPLD3416L-8', 'OPLD1818L-7', 'OPLD1818L-8', 'OPLD3416SPP-8-892', 'OPLD3416SPP-8-897', 'OPLD3416SPP-8-878', 'OPLD3416SPP-8-885', 'OPLD3416SPP-8-887', 'OPLD3416SPP-8-890', 'OPLD3416SPP-8-845', 'OPLD3416SPP-8-854', 'OPLD3416SPP-8-856', 'OPLD3416SPP-8-876', 'OPLD3416SPP-8-802', 'OPLD3416SPP-8-706', 'OPLD3416SPP-8-705', 'OPLD3416SPP-8-704', 'OPLD3416SPP-8-837', 'OPLD3416SPP-8-831', 'OPLD3416SPP-8-819', 'OPLD3416SPP-8-812', 'OPLD3416SPP-8-685', 'OPLD3416SPP-8-683', 'OPLD3416SPP-8-679', 'OPLD3416SPP-8-531', 'OPLD3416SPP-8-703', 'OPLD3416SPP-8-702', 'OPLD3416SPP-8-701', 'OPLD3416SPP-8-700', 'OPLD3416SPP-7-892', 'OPLD3416SPP-7-897', 'OPLD3416SPP-7-887', 'OPLD3416SPP-7-890', 'OPLD3416SPP-8-530', 'OPLD3416SPP-7-845', 'OPLD3416SPP-7-854', 'OPLD3416SPP-7-831', 'OPLD3416SPP-7-837', 'OPLD3416SPP-7-878', 'OPLD3416SPP-7-885', 'OPLD3416SPP-7-856', 'OPLD3416SPP-7-876', 'OPLD3416SPP-7-703', 'OPLD3416SPP-7-702', 'OPLD3416SPP-7-705', 'OPLD3416SPP-7-704', 'OPLD3416SPP-7-802', 'OPLD3416SPP-7-706', 'OPLD3416SPP-7-819', 'OPLD3416SPP-7-812', 'OPLD3416SPP-7-530', 'OPLD3416SPP-7-679', 'OPLD3416SPP-7-531', 'OPLD3416SPP-7-685', 'OPLD3416SPP-7-683', 'OPLD3416SPP-7-701', 'OPLD3416SPP-7-700', 'OPLD3416SPP-5-878', 'OPLD3416SPP-5-885', 'OPLD3416SPP-5-887', 'OPLD3416SPP-5-890', 'OPLD3416SPP-5-892', 'OPLD3416SPP-5-897', 'OPLD3416SPP-5-812', 'OPLD3416SPP-5-819', 'OPLD3416SPP-5-831', 'OPLD3416SPP-5-837', 'OPLD3416SPP-5-845', 'OPLD3416SPP-5-854', 'OPLD3416SPP-5-856', 'OPLD3416SPP-5-876', 'OPLD1818SPP-8-819', 'OPLD1818SPP-8-831', 'OPLD1818SPP-8-802', 'OPLD1818SPP-8-812', 'OPLD1818SPP-8-854', 'OPLD1818SPP-8-856', 'OPLD1818SPP-8-837', 'OPLD1818SPP-8-845', 'OPLD1818SPP-8-701', 'OPLD1818SPP-8-702', 'OPLD1818SPP-8-685', 'OPLD1818SPP-8-700', 'OPLD1818SPP-8-705', 'OPLD1818SPP-8-706', 'OPLD1818SPP-8-703', 'OPLD1818SPP-8-704', 'OPLD1818SPP-8-887', 'OPLD1818SPP-8-885', 'OPLD1818SPP-8-878', 'OPLD1818SPP-8-876', 'OPLD1818SPP-8-897', 'OPLD1818SPP-8-892', 'OPLD1818SPP-8-890', 'OPLD3416SPP-4-837', 'OPLD3416SPP-4-831', 'OPLD3416SPP-4-854', 'OPLD3416SPP-4-845', 'OPLD3416SPP-4-802', 'OPLD3416SPP-4-706',
'OPLD3416SPP-4-819', 'OPLD3416SPP-4-812', 'OPLD3416SPP-4-890', 'OPLD3416SPP-4-887', 'OPLD3416SPP-4-897', 'OPLD3416SPP-4-892', 'OPLD3416SPP-4-876', 'OPLD3416SPP-4-856', 'OPLD3416SPP-4-885', 'OPLD3416SPP-4-878', 'OPLD3416SPP-5-531', 'OPLD3416SPP-5-679', 'OPLD3416SPP-5-683', 'OPLD3416SPP-5-685', 'OPLD3416SPP-5-530', 'OPLD3416SPP-5-704', 'OPLD3416SPP-5-705', 'OPLD3416SPP-5-706', 'OPLD3416SPP-5-802', 'OPLD3416SPP-5-700', 'OPLD3416SPP-5-701', 'OPLD3416SPP-5-702', 'OPLD3416SPP-5-703', 'OPLD3416SPP-2-837', 'OPLD3416SPP-2-831', 'OPLD3416SPP-2-819', 'OPLD3416SPP-2-812', 'OPLD3416SPP-2-802', 'OPLD3416SPP-2-706', 'OPLD3416SPP-2-705', 'OPLD3416SPP-2-704', 'OPLD3416SPP-2-890', 'OPLD3416SPP-2-887', 'OPLD3416SPP-2-885', 'OPLD3416SPP-2-878', 'OPLD3416SPP-2-876', 'OPLD3416SPP-2-856', 'OPLD3416SPP-2-854', 'OPLD3416SPP-2-845', 'OPLD3416SPP-4-531', 'OPLD3416SPP-4-679', 'OPLD3416SPP-4-530', 'OPLD3416SPP-2-892', 'OPLD3416SPP-2-897', 'OPLD3416SPP-4-704', 'OPLD3416SPP-4-705', 'OPLD3416SPP-4-702', 'OPLD3416SPP-4-703', 'OPLD3416SPP-4-700', 'OPLD3416SPP-4-701', 'OPLD3416SPP-4-683', 'OPLD3416SPP-4-685', 'OPLD3416SPP-2-530', 'OPLD3416SPP-2-531', 'OPLD3416SPP-2-679', 'OPLD3416SPP-2-683', 'OPLD3416SPP-2-685', 'OPLD3416SPP-2-700', 'OPLD3416SPP-2-701', 'OPLD3416SPP-2-702', 'OPLD3416SPP-2-703', 'OPLD1818SPP-7-819', 'OPLD1818SPP-7-831', 'OPLD1818SPP-7-837', 'OPLD1818SPP-7-845', 'OPLD1818SPP-7-705', 'OPLD1818SPP-7-706', 'OPLD1818SPP-7-802', 'OPLD1818SPP-7-812', 'OPLD1818SPP-7-701', 'OPLD1818SPP-7-702', 'OPLD1818SPP-7-703', 'OPLD1818SPP-7-704', 'OPLD1818SPP-7-679', 'OPLD1818SPP-7-683', 'OPLD1818SPP-7-685', 'OPLD1818SPP-7-700', 'OPLD1818SPP-8-531', 'OPLD1818SPP-8-530', 'OPLD1818SPP-8-683', 'OPLD1818SPP-8-679', 'OPLD1818SPP-7-897', 'OPLD1818SPP-7-887', 'OPLD1818SPP-7-885', 'OPLD1818SPP-7-892', 'OPLD1818SPP-7-890', 'OPLD1818SPP-7-856', 'OPLD1818SPP-7-854', 'OPLD1818SPP-7-878', 'OPLD1818SPP-7-876', 'OPLD1818SPP-5-819', 'OPLD1818SPP-5-831', 'OPLD1818SPP-5-802', 'OPLD1818SPP-5-812', 'OPLD1818SPP-5-705', 'OPLD1818SPP-5-706', 'OPLD1818SPP-5-703', 'OPLD1818SPP-5-704', 'OPLD1818SPP-5-701', 'OPLD1818SPP-5-702', 'OPLD1818SPP-5-685', 'OPLD1818SPP-5-700', 'OPLD1818SPP-5-679', 'OPLD1818SPP-5-683', 'OPLD1818SPP-5-530', 'OPLD1818SPP-5-531', 'OPLD1818SPP-7-531', 'OPLD1818SPP-7-530', 'OPLD1818SPP-5-897', 'OPLD1818SPP-5-892', 'OPLD1818SPP-5-890', 'OPLD1818SPP-5-887', 'OPLD1818SPP-5-885', 'OPLD1818SPP-5-878', 'OPLD1818SPP-5-876', 'OPLD1818SPP-5-856', 'OPLD1818SPP-5-854', 'OPLD1818SPP-5-845', 'OPLD1818SPP-5-837', 'OPLD1818SPP-4-701', 'OPLD1818SPP-4-702', 'OPLD1818SPP-4-703', 'OPLD1818SPP-4-704', 'OPLD1818SPP-4-705', 'OPLD1818SPP-4-706', 'OPLD1818SPP-4-802', 'OPLD1818SPP-4-812', 'OPLD1818SPP-4-530', 'OPLD1818SPP-4-531', 'OPLD1818SPP-4-679', 'OPLD1818SPP-4-683', 'OPLD1818SPP-4-685', 'OPLD1818SPP-4-700', 'OPLD1818SPP-4-887', 'OPLD1818SPP-2-837', 'OPLD1818SPP-2-845', 'OPLD1818SPP-2-854', 'OPLD1818SPP-2-856', 'OPLD1818SPP-2-802', 'OPLD1818SPP-2-812', 'OPLD1818SPP-2-819', 'OPLD1818SPP-2-831', 'OPLD1818SPP-2-890', 'OPLD1818SPP-2-892', 'OPLD1818SPP-2-897', 'OPLD1818SPP-2-876', 'OPLD1818SPP-2-878', 'OPLD1818SPP-2-885', 'OPLD1818SPP-2-887', 'OPLD1818SPP-2-531', 'OPLD1818SPP-2-530', 'OPLD1818SPP-2-683', 'OPLD1818SPP-2-679', 'OPLD1818SPP-2-704', 'OPLD1818SPP-2-703',
'OPLD1818SPP-2-706', 'OPLD1818SPP-2-705', 'OPLD1818SPP-2-700', 'OPLD1818SPP-2-685', 'OPLD1818SPP-2-702', 'OPLD1818SPP-2-701', 'OPLD1818SPP-4-876', 'OPLD1818SPP-4-878', 'OPLD1818SPP-4-854', 'OPLD1818SPP-4-856', 'OPLD1818SPP-4-837', 'OPLD1818SPP-4-845', 'OPLD1818SPP-4-819', 'OPLD1818SPP-4-831', 'OPLD1818SPP-4-897', 'OPLD1818SPP-4-890', 'OPLD1818SPP-4-892', 'OPLD1818SPP-4-885', 'PLD4832DPP-2-845', 'PLD4832DPP-2-837', 'PLD4832DPP-2-856', 'PLD4832DPP-2-854', 'PLD4832DPP-2-878', 'PLD4832DPP-2-876', 'PLD4832DPP-2-887', 'PLD4832DPP-2-885', 'PLD4832DPP-2-892', 'PLD4832DPP-2-890', 'PLD4832DPP-2-897', 'PLD4832DPP-4-531', 'PLD4832DPP-4-530', 'PLD4832DPP-4-679', 'PLD4832DPP-4-683', 'PLD4832DPP-4-685', 'PLD4832DPP-4-700', 'PLD4832DPP-4-701', 'PLD4832DPP-4-702', 'PLD4832DPP-4-703', 'PLD4832DPP-4-704', 'PLD4832DPP-4-705', 'PLD4832DPP-4-706', 'PLD4832DPP-4-802', 'PLD4832DPP-4-812', 'PLD4832DPP-4-819', 'PLD4832DPP-4-831', 'PLD4832DPP-4-837', 'PLD4832DPP-4-845', 'PLD4832DPP-4-878', 'PLD4832DPP-4-876', 'PLD4832DPP-4-856', 'PLD4832DPP-4-854', 'PLD4832DPP-4-892', 'PLD4832DPP-4-890', 'PLD4832DPP-4-887', 'PLD4832DPP-4-885', 'PLD4832DPP-4-897', 'PLD4832DPP-5-683', 'PLD4832DPP-5-679', 'PLD4832DPP-5-531', 'PLD4832DPP-5-530', 'PLD4832DPP-5-701', 'PLD4832DPP-5-702', 'PLD4832DPP-5-685', 'PLD4832DPP-5-700', 'PLD4832DPP-5-705', 'PLD4832DPP-5-706', 'PLD4832DPP-5-703', 'PLD4832DPP-5-704', 'PLD4832DPP-5-819', 'PLD4832DPP-5-831', 'PLD4832DPP-5-802', 'PLD4832DPP-5-812', 'PLD4832DPP-5-854', 'PLD4832DPP-5-856', 'PLD4832DPP-5-837', 'PLD4832DPP-5-845', 'PLD4832DPP-2-701', 'PLD4832DPP-2-702', 'PLD4832DPP-2-685', 'PLD4832DPP-2-700', 'PLD4832DPP-2-679', 'PLD4832DPP-2-683', 'PLD4832DPP-2-530', 'PLD4832DPP-2-531', 'PLD4832DPP-2-819', 'PLD4832DPP-2-831', 'PLD4832DPP-2-802', 'PLD4832DPP-2-812', 'PLD4832DPP-2-705', 'PLD4832DPP-2-706', 'PLD4832DPP-2-703', 'PLD4832DPP-2-704', 'PLD4226DPP-8-887', 'PLD4226DPP-8-890', 'PLD4226DPP-8-892', 'PLD4226DPP-8-897', 'PLD4226DPP-8-856', 'PLD4226DPP-8-876', 'PLD4226DPP-8-878', 'PLD4226DPP-8-885', 'PLD4226DPP-8-831', 'PLD4226DPP-8-837', 'PLD4226DPP-8-845', 'PLD4226DPP-8-854', 'PLD4226DPP-8-706', 'PLD4226DPP-8-802', 'PLD4226DPP-8-812', 'PLD4226DPP-8-819', 'PLD4226DPP-5-892', 'PLD4226DPP-5-897', 'PLD4226DPP-5-887', 'PLD4226DPP-5-890', 'PLD4226DPP-7-530', 'PLD4226DPP-7-683', 'PLD4226DPP-7-685', 'PLD4226DPP-7-531', 'PLD4226DPP-7-679', 'PLD4226DPP-7-702', 'PLD4226DPP-7-703', 'PLD4226DPP-7-700', 'PLD4226DPP-7-701', 'PLD4226DPP-5-705', 'PLD4226DPP-5-704', 'PLD4226DPP-5-703', 'PLD4226DPP-5-702', 'PLD4226DPP-5-819', 'PLD4226DPP-5-812', 'PLD4226DPP-5-802', 'PLD4226DPP-5-706', 'PLD4226DPP-5-854', 'PLD4226DPP-5-845', 'PLD4226DPP-5-837', 'PLD4226DPP-5-831', 'PLD4226DPP-5-885', 'PLD4226DPP-5-878', 'PLD4226DPP-5-876', 'PLD4226DPP-5-856', 'PLD4226DPP-7-892', 'PLD4226DPP-7-897', 'PLD4226DPP-8-530', 'PLD4226DPP-8-531', 'PLD4226DPP-8-679', 'PLD4226DPP-8-683', 'PLD4226DPP-8-685', 'PLD4226DPP-8-700', 'PLD4226DPP-8-701', 'PLD4226DPP-8-702', 'PLD4226DPP-8-703', 'PLD4226DPP-8-704', 'PLD4226DPP-8-705', 'PLD4226DPP-7-705', 'PLD4226DPP-7-704', 'PLD4226DPP-7-802', 'PLD4226DPP-7-706', 'PLD4226DPP-7-819', 'PLD4226DPP-7-812', 'PLD4226DPP-7-837', 'PLD4226DPP-7-831', 'PLD4226DPP-7-854', 'PLD4226DPP-7-845', 'PLD4226DPP-7-876', 'PLD4226DPP-7-856', 'PLD4226DPP-7-885', 'PLD4226DPP-7-878', 'PLD4226DPP-7-890', 'PLD4226DPP-7-887', 'PLD4226DPP-2-892', 'PLD4226DPP-2-897', 'PLD4226DPP-2-887', 'PLD4226DPP-2-890', 'PLD4226DPP-2-878', 'PLD4226DPP-2-885', 'PLD4226DPP-2-856', 'PLD4226DPP-2-876', 'PLD4226DPP-4-683', 'PLD4226DPP-4-685', 'PLD4226DPP-4-531', 'PLD4226DPP-4-679', 'PLD4226DPP-4-530', 'PLD4226DPP-2-705', 'PLD4226DPP-2-704', 'PLD4226DPP-2-703', 'PLD4226DPP-2-702', 'PLD4226DPP-2-701', 'PLD4226DPP-2-700', 'PLD4226DPP-2-685', 'PLD4226DPP-2-683', 'PLD4226DPP-2-854', 'PLD4226DPP-2-845', 'PLD4226DPP-2-837', 'PLD4226DPP-2-831', 'PLD4226DPP-2-819', 'PLD4226DPP-2-812', 'PLD4226DPP-2-802', 'PLD4226DPP-2-706', 'PLD4226DPP-4-892', 'PLD4226DPP-4-897', 'PLD4226DPP-4-878', 'PLD4226DPP-4-885', 'PLD4226DPP-4-887', 'PLD4226DPP-4-890', 'PLD4226DPP-5-683', 'PLD4226DPP-5-685', 'PLD4226DPP-5-700', 'PLD4226DPP-5-701', 'PLD4226DPP-5-530', 'PLD4226DPP-5-531', 'PLD4226DPP-5-679', 'PLD4226DPP-4-705', 'PLD4226DPP-4-704', 'PLD4226DPP-4-802', 'PLD4226DPP-4-706', 'PLD4226DPP-4-701', 'PLD4226DPP-4-700', 'PLD4226DPP-4-703', 'PLD4226DPP-4-702', 'PLD4226DPP-4-854', 'PLD4226DPP-4-845', 'PLD4226DPP-4-876', 'PLD4226DPP-4-856', 'PLD4226DPP-4-819', 'PLD4226DPP-4-812', 'PLD4226DPP-4-837', 'PLD4226DPP-4-831', 'PLD4226DPP-2-530', 'PLD4226DPP-2-679', 'PLD4226DPP-2-531', 'PLD5438DPP-5-683', 'PLD5438DPP-5-685', 'PLD5438DPP-5-531', 'PLD5438DPP-5-679', 'PLD5438DPP-5-702', 'PLD5438DPP-5-703', 'PLD5438DPP-5-700', 'PLD5438DPP-5-701', 'PLD5438DPP-5-706', 'PLD5438DPP-5-802', 'PLD5438DPP-5-704', 'PLD5438DPP-5-705', 'PLD5438DPP-5-831', 'PLD5438DPP-5-837', 'PLD5438DPP-5-812', 'PLD5438DPP-5-819', 'PLD5438DPP-5-876', 'PLD5438DPP-5-856', 'PLD5438DPP-5-854', 'PLD5438DPP-5-845', 'PLD5438DPP-5-890', 'PLD5438DPP-5-887', 'PLD5438DPP-5-885', 'PLD5438DPP-5-878', 'PLD5438DPP-5-897', 'PLD5438DPP-5-892', 'PLD5438DPP-7-679', 'PLD5438DPP-7-531', 'PLD5438DPP-7-530', 'PLD5438DPP-4-530', 'PLD5438DPP-4-531', 'PLD5438DPP-4-679', 'PLD5438DPP-4-683', 'PLD5438DPP-4-685', 'PLD5438DPP-4-700', 'PLD5438DPP-4-701', 'PLD5438DPP-4-702', 'PLD5438DPP-4-703', 'PLD5438DPP-4-704', 'PLD5438DPP-4-705', 'PLD5438DPP-4-706', 'PLD5438DPP-4-802', 'PLD5438DPP-4-812', 'PLD5438DPP-4-819', 'PLD5438DPP-4-837', 'PLD5438DPP-4-831', 'PLD5438DPP-4-854', 'PLD5438DPP-4-845', 'PLD5438DPP-4-876', 'PLD5438DPP-4-856', 'PLD5438DPP-4-885', 'PLD5438DPP-4-878', 'PLD5438DPP-4-890', 'PLD5438DPP-4-887', 'PLD5438DPP-4-897', 'PLD5438DPP-4-892', 'PLD5438DPP-5-530',
'PLD5438DPP
None
the final sku in there PLD5438DPP should be PLD5438DPP-5-683 and for some reason the list cuts off there, which is only element 564/85,892, and the program terminates without an error code
I cannot attach the file of skus, this is for my job, just hoping someone can shed light on what I am doing to cause the list to cut short like that
this may or may not also be relevant but when I call .append(sku) as opposed to sku[1] and grab the whole tuple the same issue occurs but at element 292, exactly half of the amount of element appended when only doing half the tuple
The issue seems to be one on my local machine, where it was unable to print such a long list, this one was of size 85,892
for those with similar issues see if any of our specs are overlapping and that may determine the cause of this issue:
VSCode:
Version: 1.52.0 (user setup)
Commit: 940b5f4bb5fa47866a54529ed759d95d09ee80be
Date: 2020-12-10T22:45:11.850Z
Electron: 9.3.5
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Windows_NT x64 10.0.18363
Python:
3.9.0
see discussion in comments for other details

python-Binance api: APIError(code=-1013): Filter failure: LOT_SIZE

When trying to place a buy or sell order with the python-binance api I got the following error:
APIError(code=-1013): Filter failure: LOT_SIZE.
Now I've seen at iceberg_parts that this means there is probably something wrong with my buying or selling quantity. I've tried to increase the quantity by a factor 10 but this only gives me another related error:
APIError(code=-1013): Filter failure: MIN_NOTIONAL.
Here's some of my code:
diff = current_price - prev_price
if diff <= 0.0001:
order = client.order_market_buy(symbol = market , quantity = '0.0001')
print('buy order')
if diff >= 0.00040:
order = client.order_market_sell(symbol =market, quantity ='0.0001')
print('sell order')
Do you know how to fix this?
This error appears because you are trying to create an order with a quantity lower than the minimun required.
You can access the minimun required of a specific pair with:
info = client.get_symbol_info('ETHUSDT')
print(info)
Output a dictionary with information about that pair.
Now you can access the minimun quantity required with:
print(info['filters'][2]['minQty'])
# 0.00001
The buying or selling quantity has to be >= 10.3 USD or 10.3/price, pass the quantity and price to these decimal settings/filters with the amounts set with decimal
from decimal import Decimal as D, ROUND_DOWN, ROUND_UP
import decimal
info = client.get_symbol_info(symbol=pair)
price_filter = float(info['filters'][0]['tickSize'])
ticker = client.get_symbol_ticker(symbol=pair)
price = float(ticker['price'])
price = D.from_float(price).quantize(D(str(price_filter)))
minimum = float(info['filters'][2]['minQty']) # 'minQty'
quant = D.from_float(quantity).quantize(D(str(minimum))) # if quantity >= 10.3/price
I've just gone through this same problem. As a noob, some of the code in these answers seem quite complicated so I came up with a solution.
Code:
def check_decimals(symbol):
info = client.get_symbol_info(symbol)
val = info['filters'][2]['stepSize']
decimal = 0
is_dec = False
for c in val:
if is_dec is True:
decimal += 1
if c == '1':
break
if c == '.':
is_dec = True
return decimal
then when you place the order, just do for ex:
(make sure qty is a float or decimal)
B_order = round(qty / symbol_price, decimal)
order = client.order_market_buy(
symbol=symbol_name,
quantity=B_order)
Maybe this can explain why the server returns this error.
Filters
From the endpoint GET /api/v3/exchangeInfo, you can find all details regarding the trading symbols. It includes many filters that clients need to follow to place an order. For example, the BTCUSDT has the filters as of today(2022-08-31)
"filters": [
{
"filterType": "PRICE_FILTER",
"minPrice": "0.01000000",
"maxPrice": "1000000.00000000",
"tickSize": "0.01000000"
},
{
"filterType": "PERCENT_PRICE",
"multiplierUp": "5",
"multiplierDown": "0.2",
"avgPriceMins": 5
},
{
"filterType": "LOT_SIZE",
"minQty": "0.00001000",
"maxQty": "9000.00000000",
"stepSize": "0.00001000"
},
{
"filterType": "MIN_NOTIONAL",
"minNotional": "10.00000000",
"applyToMarket": true,
"avgPriceMins": 5
},
{
"filterType": "ICEBERG_PARTS",
"limit": 10
},
{
"filterType": "MARKET_LOT_SIZE",
"minQty": "0.00000000",
"maxQty": "282.39806510",
"stepSize": "0.00000000"
},
{
"filterType": "TRAILING_DELTA",
"minTrailingAboveDelta": 10,
"maxTrailingAboveDelta": 2000,
"minTrailingBelowDelta": 10,
"maxTrailingBelowDelta": 2000
},
{
"filterType": "MAX_NUM_ORDERS",
"maxNumOrders": 200
},
{
"filterType": "MAX_NUM_ALGO_ORDERS",
"maxNumAlgoOrders": 5
}
]
LOT_SIZE validation
minQty
If you place an order on this BTCUSDT with parameters:
price=19000
side=BUY
type=LIMIT
quantity=0.000005
that is a LIMIT BUY order with price of $19,000, but the quantity is less than minQty in the LOT_SIZE:
0.000005 < 0.00001000
then the server will reject the order, because the request can't pass this filter validation.
✗ LOT_SIZE.minQty
stepSize
Can I place an order with the same parameters but only change the quantity to 0.000015? That is:
price=19000
side=BUY
type=LIMIT
quantity=0.000015
You will still receive this error, because the quantity is not able to pass the stepSize size validation: (quantity- minQty) % stepSize == 0
(0.000015 - 0.00001) % 0.00001 != 0
✓ LOT_SIZE.minQty
✗ LOT_SIZE.stepSize
MIN_NOTIONAL Validation
Alright, let us change the quantity to 0.00002, with same parameters:
price=19000
side=BUY
type=LIMIT
quantity=0.00002
The order will still be rejected with a different error because it can't pass the filter MIN_NOTIONAL validation.
19000 x 0.00002 = 0.38 < 10 (MIN_NOTIONAL.minNotional)
Note:
minNotional defines the minimum notional value that required for each order.
For MARKET order, the average price is used over the last avgPriceMins minutes.
✓ LOT_SIZE.minQty
✓ LOT_SIZE.stepSize
✗ MIN_NOTIONAL.minNotional
Here is some code.
def round_down(self, coin, number):
info = self.client.get_symbol_info('%sUSDT' % coin)
step_size = [float(_['stepSize']) for _ in info['filters'] if _['filterType'] == 'LOT_SIZE'][0]
step_size = '%.8f' % step_size
step_size = step_size.rstrip('0')
decimals = len(step_size.split('.')[1])
return math.floor(number * 10 ** decimals) / 10 ** decimals
https://python-binance.readthedocs.io/en/latest/account.html
from binance.helpers import round_step_size
# to get a lot size
def getLotSize(self):
info = self.apiCall(lambda: self.client.get_symbol_info(self.pair))
lotSize = float(info['filters'][2]['minQty'])
return lotSize
# get ceiling value and correct format for a lot size
def getCeilingVal(self):
pairData = self.apiCall(lambda:
self.client.get_symbol_ticker(symbol=self.pair))
pairPrice = pairData["price"]
ceilingVal = float(self.dInv) / float(pairPrice)
aLotSize = self.getLotSize()
rounded_amount = round_step_size(ceilingVal, aLotSize)
return rounded_amount
Here's a very helpful code using binance-python package
...
// Full code: https://github.com/ndiecodes/binance-trading-bot/blob/main/main.py
def get_round_step_quantity(self, qty):
info = self.client.get_symbol_info(Config.TRADESYMBOL)
for x in info["filters"]:
if x["filterType"] == "LOT_SIZE":
self.minQty = float(x["minQty"])
self.maxQty = float(x["maxQty"])
self.stepSize= float(x["stepSize"])
if qty < self.minQty:
qty = self.minQty
return round_step_size(quantity=qty, step_size=self.stepSize)
I have read through all of these forum questions and no one has mentioned the fact that Binance charges a 0.1% fee on all transactions. Meaning you do not have your original buying quantity available to sell back when the sell is triggered.
I have attempted to solve this with:
buy_quantity = round(buy_amount * 0.999, len(str(lotsize).split('.')[1]))
Multiplying my original purchase quantity by 0.999 should reduce it by the amount needed to be able to sell it back.
Hi adding a bit further to #stack if I've 20 dollars to buy then my quantity would be as below
I've done like below
decimal_places=abs(Decimal(symbl_info['filters'][2]["stepSize"]).normalize().as_tuple().exponent)
print("DECIMAL PLACES {0}".format(decimal_places))
buy_qauntity= round((20/order_input["askPrice"].values[0]),decimal_places)
print(buy_qauntity)
I write a function like that. It's working for me.
def getPriceLotFormat(self, priceOrg, quantityOrg):
price = float(priceOrg)
quantity = float(quantityOrg)
response = self.get_symbol_info(car.pair) #self is client btw
priceFilterFloat = format(float(response["filters"][0]["tickSize"]), '.20f')
lotSizeFloat = format(float(response["filters"][2]["stepSize"]), '.20f')
# PriceFilter
numberAfterDot = str(priceFilterFloat.split(".")[1])
indexOfOne = numberAfterDot.find("1")
if indexOfOne == -1:
price = int(price)
else:
price = round(float(price), int(indexOfOne - 1))
# LotSize
numberAfterDotLot = str(lotSizeFloat.split(".")[1])
indexOfOneLot = numberAfterDotLot.find("1")
if indexOfOneLot == -1:
quantity = int(quantity)
else:
quantity = round(float(quantity), int(indexOfOneLot))
print(f"""
##### SELL #####
Pair : {str(car.pair)}
Cash : {str(car.price)}
Quantity : {str(car.quantity)}
Price : {str(car.price)}
""")
We can use the Log10 function to get rounding precision from the Binance /api/v3/exchangeinfo endpoint data.
CurrencyRoundNum = int(math.Abs(math.Log10(stepSize)))
PriceRoundNum = int(math.Abs(math.Log10(tickSize)))
The full version on golang is here, or at go playground. I'm sorry that code is not on python.
So I was struggling with the LOT_SIZE error myself.
Previously I was using the round_step_size function from the python-binance library, however, I had to edit this function to deal with this API error.
Here is a function that I use:
from decimal import Decimal, ROUND_DOWN
import math
from typing import Union
def round_step_size(quantity: Union[float, Decimal], step_size: Union[float, Decimal]) -> float:
if step_size == 1.0:
return math.floor(quantity)
elif step_size < 1.0:
return Decimal(f'{quantity}').quantize(Decimal(f'{step_size}'), rounding=ROUND_DOWN)

IF/ELSE Control flow in Python to work out price of courier service from 4 choices

I cannot seem to understand how to use if/else in the following question:
You need to design a program for a courier company to calculate the cost of sending a parcel.
Ask the user to enter the price of the package they would like to purchase.
Ask the user to enter the total distance of the delivery in kilometers.
Now, add on the delivery costs to get the final cost of the product. There are four categories to factor in when determining a parcel’s final cost, each with two options based on the customer’s delivery preferences. (Use an if else statement based on the choice they make)
Delivery via air ($0.36 per km) or via freight ($0.25 per km)
Full insurance ($50.00) or limited insurance ($25.00)
Gift option ($15.00) or not ($0.00)
Priority delivery ($100.00) or standard delivery ($20.00)
Write code to work out the total cost of the package based on the options
selected in each category.
#Mohseen Ramjan
I used some of the original code, but simplified it a bit.
I am no expert, and I'm sure even this code can be improved a lot.
===== NOTE: our currency is Rand, thus the use of the 'R' =====
But maybe you'll understand this a bit better:
main_product_price = int(float(input("""Please enter the price of the package you would like to purchase:
(Only use numbers, do not inlcude 'R')\n""")))
total_distance = int(float(input("\nPlease enter the total distance of the delivery in Kilometers:\n")))
print ("\nNow please choose your shipping preferences;")
print ("\nWould you prefere Air at R0.36 per km, or Freight at R0.25 per km?")
freight_choise = input("Enter: 'Air' or 'Freight'\n")
cost_per_distance = 0
if freight_choise in ['Freight']:
cost_per_distance = 0.25
elif freight_choise in ['Air']:
cost_per_distance = 0.36
print ("\nWould you prefere Full insurance (R50.00), or Limited insurance (R25.00)?")
insurance_choise = input("Enter: 'Full' or 'Limited'?\n")
insurance_cost = 0
if insurance_choise in ['Full']:
insurance_cost = 50
elif insurance_choise in ['Limited']:
insurance_cost = 25
print ("\nWould you like to add a Gift for R15.00?")
gift_choise = input("Enter: 'Yes please' or 'No thanks'\n")
gift_cost = 0
if gift_choise in ['Yes please']:
gift_cost = 15
elif gift_choise in ['No thanks']:
gift_cost = 0
print ("\nWould you prefere Priority delivery for R100.00, or Standard delivery for R20.00?")
delivery_choise = input("Enter: 'Priority' or 'Standard'\n")
priority_or_standard_delivery = 0
if delivery_choise in ['Priority']:
priority_or_standard_delivery = 100
elif delivery_choise in ['Standard']:
priority_or_standard_delivery = 20
total_cost = main_product_price + total_distance*cost_per_distance + insurance_cost + gift_cost + priority_or_standard_delivery
print (f"""\nThis is your Total cost:
R{total_cost}""")
# Courier cost of delivering parcel
# You can and should add your own assertions and checks if the user input is valid
# I used a list instead of '==' so that you can expand the response options
# There are many other ways to do it, this is just my quick and dirty method
# But I suppose you could iterate from here
def user_input():
price_of_package = float(input('Input price of package.\n'))
total_distance = float(input('Input total distance in km\n'))
freight_or_air = input('Input freight or air delivery?\n').lower()
full_or_limited_insurance = input('Input full or limited insurance?\n').lower()
gift_or_not = input('Is this a gift?\n').lower()
priority_or_standard = input('Is this priority or standard delivery?\n').lower()
cost_per_distance = 0
if freight_or_air in ['freight']:
cost_per_distance = 0.25
elif freight_or_air in ['air']:
cost_per_distance = 0.36
cost_of_insurance = 0
if full_or_limited_insurance in ['full']:
cost_of_insurance = 50.00
elif full_or_limited_insurance in ['limited']:
cost_of_insurance = 25.00
cost_of_gift = 0
if gift_or_not in ['yes']:
cost_of_gift = 15
cost_of_delivery = 0
if priority_or_standard in ['priority']:
cost_of_delivery = 100
elif priority_or_standard in ['standard']:
cost_of_delivery = 20
print (f'\nThe user has specified that\n\
price of package: {price_of_package}\n\
total distance: {total_distance}\n\
freight or air: {freight_or_air}\n\
cost per distance {cost_per_distance}\n\
type of insurance: {full_or_limited_insurance}\n\
cost of insurance: {cost_per_distance}\n\
if it is a gift: {gift_or_not}\n\
cost of gift: {cost_of_gift}\n\
type of delivery: {priority_or_standard}\n\
cost of delivery: {cost_of_delivery}.')
return price_of_package, total_distance, cost_per_distance,\
cost_of_insurance, cost_of_gift, cost_of_delivery
def total_cost():
price_of_package, total_distance, cost_per_distance,\
cost_of_insurance, cost_of_gift, cost_of_delivery = user_input()
total_cost = price_of_package + total_distance*cost_per_distance +\
cost_of_insurance + cost_of_gift + cost_of_delivery
print (f'\nThe total cost is {total_cost}.')
return total_cost

Tkinter error type variable [duplicate]

This question already has answers here:
Why is my Button's command executed immediately when I create the Button, and not when I click it? [duplicate]
(5 answers)
Closed 6 years ago.
I am an electrical engineer and I am new to Python programming.
I want to write a Python program for three phase transformer calculator. The program is very simple, it does just a few algebraic operation; I wrote simple python code without GUI and it worked very fine. So I decided to make the same program using Tkinter module to give a GUI to my application. I had some error and I read a lot of questions and asked many questions on this community, but I am not able to solve it. I am not able to trace the cause of the error. The code is:
from tkinter import *
from math import *
finestra=Tk()
finestra.geometry('800x800+300+300')
finestra.title('Dimensionamento Trasformatore')
def calcola(Vn,Vn2,Sn,Vcc,V_spira,f,Bmax,mu,J,w,Snf,N1,N2,If1,If2,kv,ki,fi,fi_c,S_colonna,S_conduttore1,S_conduttore2,Sezione_netta_cu1,Sezione_netta_cu2,Vf1,Vf2):
try:
#lettura caselle di testo/ read entry
Vn=float(Vn_s.get())
Vn2=float(Vn2_s.get())
Vcc=float(Vcc_s.get())
V_spira=float(Vspira_s.get())
Sn=float(Sn_s.get())
J=float(J_s.get())
mu=float(mu_s.get())
Bmax=float(Bmax_s.get())
f=float(f_s.get())
except ValueError:
print('inserito valore sbagliato')
else:
#calcoli / calculate
if (var_1.get()==1):
collegamento1='triangolo'
else:
collegamento1='stella'
if (var_2.get()==1):
collegamento2='triangolo'
else:
collegamento2='stella'
Snf=(Sn/3.0)
w=(2*pi*f)
if (collegamento1=='triangolo'):
Vf1=Vn
else:
Vf1=(Vn/sqrt(3))
if (collegamento2=='triangolo'):
Vf2=(Vn2)
else:
Vf2=(Vn2/sqrt(3))
N1=Vf1/V_spira
N2=Vf2/V_spira
If1=Snf/Vf1
If2=(Snf/Vf2)
kv=Vf1/Vf2
ki=If2/If1
fi=Vf1/(w*N1)
fi_c=(N1*fi)
S_colonna=(fi_c/(Bmax*sqrt(2)))
S_conduttore1=(If1/J)
S_conduttore2=(If2/J)
# Sezione_netta_cu1.set(S_conduttore1*N1/k_stip_cu)
# Sezione_netta_cu2.set(S_conduttore2*N2/k_stip_cu)
testo_23=Label(finestra,text=str(N1)).grid(sticky=W,row=4,column=5)
testo_24=Label(finestra,text=str(N2)).grid(sticky=W,row=6,column=5)
testo_25=Label(finestra,text=str(kv)).grid(sticky=W,row=11,column=5)
testo_26=Label(finestra,text=str(ki)).grid(sticky=W,row=13,column=5)
testo_27=Label(finestra,text=str(fi_c)).grid(sticky=W,row=21,column=5)
testo_28=Label(finestra,text=str(S_colonna)).grid(sticky=W,row=25,column=5)
testo_29=Label(finestra,text=str(S_conduttore1)).grid(sticky=W,row=19,column=5)
testo_30=Label(finestra,text=str(S_conduttore2)).grid(sticky=W,row=17,column=5)
## testo_31=Label(finestra,text=str(Sezione_netta_cu1)).grid(sticky=W,row=16,column=5)
## testo_32=Label(finestra,text=str(Sezione_netta_cu2)).grid(sticky=W,row=8,column=5)
## testo_33=Label(finestra,text=str(N1)).grid(sticky=W,row=14,column=5)
## testo_34=Label(finestra,text=str(N1)).grid(sticky=W,row=22,column=5)
return;
#Testi / label
testo_0=Label(finestra,text="Parametri di ingresso:").grid(sticky=W,row=0,column=0)
testo_1=Label(finestra,text="Collegamento primario:").grid(sticky=W,row=3,column=0)
testo_2=Label(finestra,text="Collegamento secondario:").grid(sticky=W,row=5,column=0)
testo_3=Label(finestra,text="Tensione nominale concatenata primaria:").grid(sticky=W,row=10,column=0)
testo_4=Label(finestra,text="Tensione nominale concatenata secondaria:").grid(sticky=W,row=12,column=0)
testo_5=Label(finestra,text="Induzione massima:").grid(sticky=W,row=20,column=0)
testo_6=Label(finestra,text="Densita di corrente:").grid(sticky=W,row=24,column=0)
testo_7=Label(finestra,text="Frequenza:").grid(sticky=W,row=18,column=0)
testo_8=Label(finestra,text="Tensione di corto circuito:").grid(sticky=W,row=16,column=0)
testo_9=Label(finestra,text="Potenza apparente nominale:").grid(sticky=W,row=8,column=0)
testo_10=Label(finestra,text="Volt-spira:").grid(sticky=W,row=14,column=0)
testo_11=Label(finestra,text="Permeabilita del ferro:").grid(sticky=W,row=22,column=0)
testo_12=Label(finestra,text="Valori calcolati:").grid(sticky=W,row=0,column=5)
testo_13=Label(finestra,text="Numero spire primario:").grid(sticky=W,row=3,column=5)
testo_14=Label(finestra,text="Numero spire secondario:").grid(sticky=W,row=5,column=5)
testo_15=Label(finestra,text="Rapporto trasformazione tensione:").grid(sticky=W,row=10,column=5)
testo_16=Label(finestra,text="Rapporto trasformazione corrente:").grid(sticky=W,row=12,column=5)
testo_17=Label(finestra,text="Flusso concatenato efficace:").grid(sticky=W,row=20,column=5)
testo_18=Label(finestra,text="Sezione colonna:").grid(sticky=W,row=24,column=5)
testo_19=Label(finestra,text="Sezione conduttore primario:").grid(sticky=W,row=18,column=5)
testo_20=Label(finestra,text="Sezione conduttore secondario:").grid(sticky=W,row=16,column=5)
testo_21=Label(finestra,text="Sezione avvolgimento primario netta:").grid(sticky=W,row=8,column=5)
testo_22=Label(finestra,text="Sezione avvolgimento secondario netta:").grid(sticky=W,row=14,column=5)
#variabili
If1=DoubleVar()
If2=DoubleVar()
N1=DoubleVar()
N2=DoubleVar()
var_1=IntVar()
var_2=IntVar()
Vn=DoubleVar()
Vf1=DoubleVar()
Vf2=DoubleVar()
Vn2=DoubleVar()
Vcc=DoubleVar()
V_spira=DoubleVar()
Sn=DoubleVar()
Snf=DoubleVar()
J=DoubleVar()
mu=DoubleVar()
Bmax=DoubleVar()
f=DoubleVar()
Vn_s=StringVar()
Vn2_s=StringVar()
Vcc_s=StringVar()
Vspira_s=StringVar()
Sn_s=StringVar()
J_s=StringVar()
mu_s=StringVar()
Bmax_s=StringVar()
f_s=StringVar()
collegamento1=StringVar()
collegamento2=StringVar()
w=DoubleVar()
kv=DoubleVar()
ki=DoubleVar()
fi=DoubleVar()
fi_c=DoubleVar()
S_colonna=DoubleVar()
S_conduttore1=DoubleVar()
S_conduttore2=DoubleVar()
Sezione_netta_cu1=DoubleVar()
Sezione_netta_cu2=DoubleVar()
#Radiobutton
#collegamento primario/ first winding
collegamentoI_1=Radiobutton(finestra,text='triangolo',value=1,variable=var_1)
collegamentoI_1.grid(row=4,column=0)
collegamentoI_2=Radiobutton(finestra,text='stella',value=2,variable=var_1)
collegamentoI_2.grid(row=4,column=1)
#collegamento secondario/ second winding
collegamentoII_1=Radiobutton(finestra,text='triangolo',value=1,variable=var_2)
collegamentoII_1.grid(row=6,column=0)
collegamentoII_2=Radiobutton(finestra,text='stella',value=2,variable=var_2)
collegamentoII_2.grid(row=6,column=1)
#caselle di testo / entry
Vn_=Entry(finestra,textvariable=Vn_s)
Vn_.grid(row=11,column=0)
Vspira_=Entry(finestra,textvariable=Vspira_s)
Vspira_.grid(row=15,column=0)
Vn2_=Entry(finestra,textvariable=Vn2_s)
Vn2_.grid(row=13,column=0)
Sn_=Entry(finestra,textvariable=Sn_s)
Sn_.grid(row=9,column=0)
Bmax_=Entry(finestra,textvariable=Bmax_s)
Bmax_.grid(row=21,column=0)
mu_=Entry(finestra,textvariable=mu_s)
mu_.grid(row=23,column=0)
Vcc_=Entry(finestra,textvariable=Vcc_s)
Vcc_.grid(row=17,column=0)
f_=Entry(finestra,textvariable=f_s)
f_.grid(row=19,column=0)
J_=Entry(finestra,textvariable=J_s)
J_.grid(row=25,column=0)
#Calculatebutton
gobutton=Button(finestra,text='Calcola',command=calcola(Vn,Vn2,Sn,Vcc,V_spira,f,Bmax,mu,J,w,Snf,N1,N2,If1,If2,kv,ki,fi,fi_c,S_colonna,S_conduttore1,S_conduttore2,Sezione_netta_cu1,Sezione_netta_cu2,Vf1,Vf2))
gobutton.grid(row=28, column=3)
finestra.mainloop()
The first kind of error I had was a ValueError: could not convert string to float. I read this could happen because at the start time, the entry widgets are empty so python can convert it to float. So I added try/except block. Now when I start the program, it prints an error message in except block (I can't understand this: the calcola function is associated to the calculate button, but it seems to run the function without button press, at start time) then don't happen anything else, though writing number in entry box and pressing calculate button. What I suspect is that the way I am using function is wrong (syntax or something else). If anyone can help me, I'd really appreciate.
Sorry for bad English. Thank you very much.
Nicola
when passing parameters through your function if it is called by a tkinter button you should always use the lambda statement like this: Button(finestra,text='Calcola',command=lambda: calcola(paramaters..) or the function will be called just once when the program starts.
your code:
from tkinter import *
from math import *
finestra=Tk()
finestra.geometry('800x800+300+300')
finestra.title('Dimensionamento Trasformatore')
def calcola(Vn,Vn2,Sn,Vcc,V_spira,f,Bmax,mu,J,w,Snf,N1,N2,If1,If2,kv,ki,fi,fi_c,S_colonna,S_conduttore1,S_conduttore2,Sezione_netta_cu1,Sezione_netta_cu2,Vf1,Vf2):
try:
#lettura caselle di testo/ read entry
Vn=float(Vn_s.get())
Vn2=float(Vn2_s.get())
Vcc=float(Vcc_s.get())
V_spira=float(Vspira_s.get())
Sn=float(Sn_s.get())
J=float(J_s.get())
mu=float(mu_s.get())
Bmax=float(Bmax_s.get())
f=float(f_s.get())
except ValueError:
print('inserito valore sbagliato')
else:
#calcoli / calculate
if (var_1.get()==1):
collegamento1='triangolo'
else:
collegamento1='stella'
if (var_2.get()==1):
collegamento2='triangolo'
else:
collegamento2='stella'
Snf=(Sn/3.0)
w=(2*pi*f)
if (collegamento1=='triangolo'):
Vf1=Vn
else:
Vf1=(Vn/sqrt(3))
if (collegamento2=='triangolo'):
Vf2=(Vn2)
else:
Vf2=(Vn2/sqrt(3))
N1=Vf1/V_spira
N2=Vf2/V_spira
If1=Snf/Vf1
If2=(Snf/Vf2)
kv=Vf1/Vf2
ki=If2/If1
fi=Vf1/(w*N1)
fi_c=(N1*fi)
S_colonna=(fi_c/(Bmax*sqrt(2)))
S_conduttore1=(If1/J)
S_conduttore2=(If2/J)
# Sezione_netta_cu1.set(S_conduttore1*N1/k_stip_cu)
# Sezione_netta_cu2.set(S_conduttore2*N2/k_stip_cu)
testo_23=Label(finestra,text=str(N1)).grid(sticky=W,row=4,column=5)
testo_24=Label(finestra,text=str(N2)).grid(sticky=W,row=6,column=5)
testo_25=Label(finestra,text=str(kv)).grid(sticky=W,row=11,column=5)
testo_26=Label(finestra,text=str(ki)).grid(sticky=W,row=13,column=5)
testo_27=Label(finestra,text=str(fi_c)).grid(sticky=W,row=21,column=5)
testo_28=Label(finestra,text=str(S_colonna)).grid(sticky=W,row=25,column=5)
testo_29=Label(finestra,text=str(S_conduttore1)).grid(sticky=W,row=19,column=5)
testo_30=Label(finestra,text=str(S_conduttore2)).grid(sticky=W,row=17,column=5)
## testo_31=Label(finestra,text=str(Sezione_netta_cu1)).grid(sticky=W,row=16,column=5)
## testo_32=Label(finestra,text=str(Sezione_netta_cu2)).grid(sticky=W,row=8,column=5)
## testo_33=Label(finestra,text=str(N1)).grid(sticky=W,row=14,column=5)
## testo_34=Label(finestra,text=str(N1)).grid(sticky=W,row=22,column=5)
return;
#Testi / label
testo_0=Label(finestra,text="Parametri di ingresso:").grid(sticky=W,row=0,column=0)
testo_1=Label(finestra,text="Collegamento primario:").grid(sticky=W,row=3,column=0)
testo_2=Label(finestra,text="Collegamento secondario:").grid(sticky=W,row=5,column=0)
testo_3=Label(finestra,text="Tensione nominale concatenata primaria:").grid(sticky=W,row=10,column=0)
testo_4=Label(finestra,text="Tensione nominale concatenata secondaria:").grid(sticky=W,row=12,column=0)
testo_5=Label(finestra,text="Induzione massima:").grid(sticky=W,row=20,column=0)
testo_6=Label(finestra,text="Densita di corrente:").grid(sticky=W,row=24,column=0)
testo_7=Label(finestra,text="Frequenza:").grid(sticky=W,row=18,column=0)
testo_8=Label(finestra,text="Tensione di corto circuito:").grid(sticky=W,row=16,column=0)
testo_9=Label(finestra,text="Potenza apparente nominale:").grid(sticky=W,row=8,column=0)
testo_10=Label(finestra,text="Volt-spira:").grid(sticky=W,row=14,column=0)
testo_11=Label(finestra,text="Permeabilita del ferro:").grid(sticky=W,row=22,column=0)
testo_12=Label(finestra,text="Valori calcolati:").grid(sticky=W,row=0,column=5)
testo_13=Label(finestra,text="Numero spire primario:").grid(sticky=W,row=3,column=5)
testo_14=Label(finestra,text="Numero spire secondario:").grid(sticky=W,row=5,column=5)
testo_15=Label(finestra,text="Rapporto trasformazione tensione:").grid(sticky=W,row=10,column=5)
testo_16=Label(finestra,text="Rapporto trasformazione corrente:").grid(sticky=W,row=12,column=5)
testo_17=Label(finestra,text="Flusso concatenato efficace:").grid(sticky=W,row=20,column=5)
testo_18=Label(finestra,text="Sezione colonna:").grid(sticky=W,row=24,column=5)
testo_19=Label(finestra,text="Sezione conduttore primario:").grid(sticky=W,row=18,column=5)
testo_20=Label(finestra,text="Sezione conduttore secondario:").grid(sticky=W,row=16,column=5)
testo_21=Label(finestra,text="Sezione avvolgimento primario netta:").grid(sticky=W,row=8,column=5)
testo_22=Label(finestra,text="Sezione avvolgimento secondario netta:").grid(sticky=W,row=14,column=5)
#variabili
If1=DoubleVar()
If2=DoubleVar()
N1=DoubleVar()
N2=DoubleVar()
var_1=IntVar()
var_2=IntVar()
Vn=DoubleVar()
Vf1=DoubleVar()
Vf2=DoubleVar()
Vn2=DoubleVar()
Vcc=DoubleVar()
V_spira=DoubleVar()
Sn=DoubleVar()
Snf=DoubleVar()
J=DoubleVar()
mu=DoubleVar()
Bmax=DoubleVar()
f=DoubleVar()
Vn_s=StringVar()
Vn2_s=StringVar()
Vcc_s=StringVar()
Vspira_s=StringVar()
Sn_s=StringVar()
J_s=StringVar()
mu_s=StringVar()
Bmax_s=StringVar()
f_s=StringVar()
collegamento1=StringVar()
collegamento2=StringVar()
w=DoubleVar()
kv=DoubleVar()
ki=DoubleVar()
fi=DoubleVar()
fi_c=DoubleVar()
S_colonna=DoubleVar()
S_conduttore1=DoubleVar()
S_conduttore2=DoubleVar()
Sezione_netta_cu1=DoubleVar()
Sezione_netta_cu2=DoubleVar()
#Radiobutton
#collegamento primario/ first winding
collegamentoI_1=Radiobutton(finestra,text='triangolo',value=1,variable=var_1)
collegamentoI_1.grid(row=4,column=0)
collegamentoI_2=Radiobutton(finestra,text='stella',value=2,variable=var_1)
collegamentoI_2.grid(row=4,column=1)
#collegamento secondario/ second winding
collegamentoII_1=Radiobutton(finestra,text='triangolo',value=1,variable=var_2)
collegamentoII_1.grid(row=6,column=0)
collegamentoII_2=Radiobutton(finestra,text='stella',value=2,variable=var_2)
collegamentoII_2.grid(row=6,column=1)
#caselle di testo / entry
Vn_=Entry(finestra,textvariable=Vn_s)
Vn_.grid(row=11,column=0)
Vspira_=Entry(finestra,textvariable=Vspira_s)
Vspira_.grid(row=15,column=0)
Vn2_=Entry(finestra,textvariable=Vn2_s)
Vn2_.grid(row=13,column=0)
Sn_=Entry(finestra,textvariable=Sn_s)
Sn_.grid(row=9,column=0)
Bmax_=Entry(finestra,textvariable=Bmax_s)
Bmax_.grid(row=21,column=0)
mu_=Entry(finestra,textvariable=mu_s)
mu_.grid(row=23,column=0)
Vcc_=Entry(finestra,textvariable=Vcc_s)
Vcc_.grid(row=17,column=0)
f_=Entry(finestra,textvariable=f_s)
f_.grid(row=19,column=0)
J_=Entry(finestra,textvariable=J_s)
J_.grid(row=25,column=0)
#Calculatebutton
gobutton=Button(finestra,text='Calcola',command=lambda: calcola(Vn,Vn2,Sn,Vcc,V_spira,f,Bmax,mu,J,w,Snf,N1,N2,If1,If2,kv,ki,fi,fi_c,S_colonna,S_conduttore1,S_conduttore2,Sezione_netta_cu1,Sezione_netta_cu2,Vf1,Vf2))
gobutton.grid(row=28, column=3)
finestra.mainloop()

Categories

Resources