Jan-13-2019, 10:57 AM
(This post was last modified: Jan-13-2019, 10:58 AM by AFKManager.)
Hey i need to write a code for my teacher, he said Write a code that will have three 3digit numbers in it and if the number contains 0 f.e. 300,301 or so it will be removed. Afterwards i need to sum the numbers that are left.
So far i created a list with 3 variables in it a,b,c and before i defined a,b,c as random.randint(111,999) so it will be a 3 digit number.
My problem is that i dont know how to find a specific thing in a number. I tried changing the a to string and then doing if 0 in a: /nameoflist/.remove(a) but idk
Note: cisla is name of list and in english it means numbers so u wont get confused :D
So far i created a list with 3 variables in it a,b,c and before i defined a,b,c as random.randint(111,999) so it will be a 3 digit number.
My problem is that i dont know how to find a specific thing in a number. I tried changing the a to string and then doing if 0 in a: /nameoflist/.remove(a) but idk
1 2 3 4 5 6 7 8 9 |
import random a = [random.randint( 111 , 1000 )] b = [random.randint( 111 , 1000 )] c = [random.randint( 111 , 1000 )] cisla = [a,b,c] str (a) if 0 in a: cisla.remove(a) print (cisla) |