In [168]:
'''
Time taken for ten list:
CPU times: user 2 µs, sys: 0 ns, total: 2 µs
Wall time: 5.96 µs

Time taken for hundred list: 
CPU times: user 2 µs, sys: 0 ns, total: 2 µs
Wall time: 4.05 µs

Time taken for thousand list: 
CPU times: user 4 µs, sys: 1 µs, total: 5 µs
Wall time: 8.11 µs
'''
import random
random_list = []
#d = search item

index = 0
for a in random_list: 
    if a == d: 
        print("The index for the search item is " + str(index))
    else:
        index += 1 
        
        if index > len(random_list):  
            print("Search item not in list")
            break

In [191]:
random_list = random.sample(range(1, 11), 10) 
d = random.choice(random_list) 
print(d)
print(random_list)


9
[9, 6, 4, 3, 8, 7, 5, 10, 2, 1]

In [192]:
index = 0
for a in random_list: 
    if a == d: 
        print("The index for the search item is " + str(index))
    else:
        index += 1 
        
        if index1 > len(random_list):  
            print("Search item not in list")
            break 

#%time(random_list)


The index for the search item is 0

In [206]:
random_list = random.sample(range(1, 101), 100)
d = random.choice(random_list)
print(d)
print(random_list)


96
[15, 42, 79, 78, 73, 3, 85, 28, 41, 5, 31, 69, 16, 53, 38, 4, 40, 64, 20, 12, 94, 30, 25, 37, 48, 81, 97, 9, 71, 26, 11, 95, 84, 83, 50, 89, 36, 62, 99, 100, 21, 58, 35, 7, 87, 13, 93, 32, 14, 55, 8, 29, 90, 88, 63, 22, 18, 70, 57, 51, 27, 33, 72, 24, 6, 52, 10, 96, 49, 80, 17, 61, 98, 67, 44, 54, 59, 86, 47, 66, 75, 65, 2, 45, 74, 82, 68, 92, 91, 43, 1, 76, 60, 23, 19, 34, 77, 56, 46, 39]

In [207]:
index = 0
for a in random_list:
    if a == d:
        print("The index for the search item is " + str(index))
    else:
        index += 1 
        
        if index > len(random_list):
            print("Search item not in list")
            break

#%time(random_list)


The index for the search item is 67

In [205]:
random_list = random.sample(range(1, 1001), 1000)
d = random.choice(random_list)
print(d)
print(random_list)


503
[262, 837, 17, 550, 849, 847, 710, 702, 51, 270, 698, 421, 16, 495, 483, 475, 403, 571, 120, 352, 894, 397, 697, 784, 906, 559, 787, 166, 360, 756, 331, 811, 245, 71, 201, 267, 949, 808, 560, 713, 410, 318, 614, 282, 621, 943, 920, 549, 64, 394, 227, 538, 589, 49, 878, 305, 345, 346, 868, 499, 686, 69, 241, 504, 579, 200, 719, 620, 838, 269, 234, 635, 948, 249, 766, 62, 73, 613, 798, 898, 884, 524, 90, 685, 63, 709, 671, 287, 519, 250, 489, 762, 745, 188, 297, 83, 874, 99, 202, 468, 822, 841, 843, 588, 692, 327, 585, 429, 276, 459, 891, 653, 219, 325, 647, 125, 575, 688, 272, 723, 230, 676, 534, 601, 342, 728, 970, 578, 478, 391, 57, 783, 717, 205, 563, 431, 699, 989, 119, 109, 786, 800, 770, 68, 215, 934, 854, 590, 379, 357, 533, 892, 869, 465, 788, 648, 888, 561, 980, 996, 38, 486, 48, 455, 258, 750, 256, 551, 520, 171, 408, 277, 278, 2, 893, 376, 237, 968, 365, 442, 97, 222, 47, 114, 348, 156, 23, 289, 929, 150, 82, 484, 178, 452, 9, 362, 381, 577, 936, 253, 438, 645, 961, 845, 876, 25, 229, 777, 663, 461, 243, 491, 299, 226, 228, 543, 729, 939, 235, 803, 597, 552, 605, 582, 482, 433, 364, 817, 261, 426, 954, 611, 204, 167, 672, 199, 734, 343, 172, 20, 522, 153, 492, 967, 511, 414, 521, 423, 384, 182, 61, 101, 633, 616, 732, 712, 500, 515, 301, 918, 846, 587, 720, 238, 708, 405, 144, 448, 214, 417, 527, 427, 285, 952, 96, 928, 966, 268, 805, 462, 207, 8, 946, 107, 886, 982, 979, 463, 871, 510, 540, 767, 457, 136, 998, 781, 938, 366, 655, 883, 110, 594, 557, 223, 880, 882, 339, 59, 404, 987, 599, 965, 615, 630, 406, 472, 24, 412, 321, 725, 769, 632, 476, 640, 836, 39, 65, 528, 990, 240, 72, 104, 637, 132, 184, 859, 682, 665, 288, 643, 155, 447, 443, 300, 111, 7, 464, 760, 693, 950, 422, 280, 34, 558, 296, 772, 257, 814, 122, 244, 26, 50, 95, 236, 347, 108, 506, 809, 625, 315, 79, 626, 32, 147, 340, 638, 485, 370, 828, 106, 530, 776, 974, 189, 942, 218, 440, 752, 454, 501, 909, 881, 30, 293, 586, 43, 574, 569, 973, 471, 850, 997, 375, 612, 307, 664, 969, 848, 545, 220, 260, 251, 170, 825, 813, 921, 275, 76, 165, 802, 124, 902, 413, 185, 660, 198, 858, 6, 248, 224, 765, 758, 105, 650, 460, 701, 799, 509, 978, 730, 624, 806, 333, 537, 386, 133, 737, 191, 197, 13, 128, 221, 292, 634, 890, 887, 31, 142, 316, 361, 654, 873, 573, 912, 396, 266, 821, 314, 782, 791, 816, 877, 824, 546, 900, 957, 135, 157, 213, 212, 885, 324, 505, 35, 694, 567, 863, 566, 1, 371, 74, 10, 52, 380, 281, 12, 507, 914, 319, 763, 722, 451, 112, 542, 208, 985, 677, 126, 141, 553, 572, 11, 704, 747, 264, 187, 951, 247, 493, 687, 935, 922, 383, 617, 831, 593, 916, 556, 795, 368, 402, 716, 514, 445, 535, 736, 263, 308, 424, 163, 355, 118, 503, 740, 705, 100, 192, 390, 94, 378, 908, 349, 393, 768, 458, 502, 151, 29, 674, 993, 416, 46, 295, 580, 18, 796, 154, 834, 1000, 603, 395, 718, 85, 326, 146, 926, 450, 271, 399, 675, 206, 239, 627, 44, 606, 103, 387, 971, 449, 469, 826, 857, 58, 127, 670, 91, 958, 827, 529, 273, 335, 312, 389, 933, 947, 623, 195, 113, 209, 759, 138, 434, 889, 302, 815, 690, 162, 86, 407, 481, 930, 211, 741, 183, 242, 437, 583, 865, 480, 744, 925, 328, 667, 910, 400, 89, 941, 255, 596, 646, 22, 216, 164, 642, 994, 19, 477, 372, 789, 754, 494, 444, 707, 435, 696, 731, 419, 512, 917, 70, 353, 439, 999, 344, 42, 41, 311, 358, 337, 37, 388, 532, 392, 711, 790, 976, 652, 812, 649, 80, 143, 819, 785, 832, 554, 794, 398, 401, 683, 432, 896, 508, 158, 727, 149, 180, 66, 735, 764, 338, 259, 516, 739, 536, 310, 629, 225, 911, 866, 81, 420, 541, 513, 385, 190, 959, 175, 879, 117, 631, 446, 905, 232, 986, 283, 168, 931, 5, 203, 274, 518, 279, 568, 833, 77, 940, 992, 927, 602, 864, 487, 490, 284, 860, 924, 28, 254, 351, 932, 382, 33, 159, 303, 853, 657, 751, 21, 595, 336, 130, 177, 856, 903, 294, 356, 842, 173, 609, 793, 962, 622, 36, 40, 373, 695, 656, 322, 329, 231, 102, 441, 706, 286, 673, 544, 116, 608, 641, 991, 872, 726, 14, 773, 411, 453, 953, 757, 937, 955, 779, 134, 977, 755, 840, 161, 75, 369, 186, 55, 45, 525, 210, 659, 194, 852, 981, 176, 592, 137, 923, 27, 547, 823, 92, 526, 742, 604, 771, 839, 570, 354, 804, 607, 313, 334, 895, 761, 466, 829, 60, 983, 217, 565, 738, 778, 901, 862, 644, 456, 363, 428, 78, 870, 56, 320, 436, 367, 88, 919, 350, 975, 807, 988, 298, 801, 715, 733, 775, 145, 317, 548, 140, 724, 780, 600, 169, 98, 129, 115, 323, 418, 680, 749, 562, 123, 746, 121, 53, 581, 818, 93, 246, 861, 844, 479, 681, 743, 160, 148, 944, 618, 668, 497, 425, 15, 584, 3, 661, 913, 995, 679, 639, 488, 531, 619, 689, 658, 555, 332, 703, 233, 669, 193, 415, 753, 774, 291, 628, 907, 181, 467, 498, 714, 915, 474, 684, 309, 496, 84, 252, 963, 598, 748, 359, 54, 855, 792, 539, 174, 306, 409, 651, 523, 662, 330, 964, 576, 960, 666, 956, 899, 610, 984, 945, 377, 4, 904, 341, 304, 867, 897, 564, 700, 131, 517, 67, 470, 972, 430, 473, 374, 820, 810, 179, 265, 830, 636, 691, 835, 290, 678, 87, 139, 196, 721, 591, 851, 152, 875, 797]

In [200]:
index = 0
for a in random_list:
    if a == d:
        print("The index for the search item is " + str(index))
    else:
        index += 1 
        
        if index > len(random_list):
            print("Search item not in list")
            break

#%time(random_list)


The index for the search item is 553

In [186]:
index = 10000    
for a in random_list:
    if a == d:
        print("The index for the search item is " + str(index))
    else:
        index += 1 
        
        if index > len(random_list):
            print("Search item not in list")
            break


Search item not in list