Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0301· OpenAIAi2 WildChat-4.8M (AI2)

Given a list of integers, find the first maximum element in it. Print its value and its…

  1. User

    Given a list of integers, find the first maximum element in it. Print its value and its index (counting with 0). use lists and strings only, include a = [int(s) for s in input().split()] and a print statement.

  2. Assistant

    a = [int(s) for s in input().split()]

    max_value = a[0] max_index = 0

    for i in range(1, len(a)): if a[i] > max_value: max_value = a[i] max_index = i

    print("Max value:", max_value) print("Index:", max_index)