Hello good day guys. I just want to ask for help in my java python. I am just new in this language.
MY first java language is java. However, for me to make it easier to code in python, i need to code it in java first and then convert after. But i am confused working with arrays in python, help me guys. Thank you.

import java.util.*;

public class sample {
	static Scanner scan = new Scanner(System.in);
	public static void main (String args[]){
	public static void sample(){
		System.out.println("Enter numbers : ");
		String input[] = new String[5];
		for ( int i = 0 ; i < input.length; i++){
			input[i] = scan.nextLine();
		for ( int i = 0 ; i < input.length; i++){	

Edited by vegaseat: n/a

8 Years
Discussion Span
Last Post by vegaseat

Which version of Python are you using?

Using Python2 you would use something like this to create an array of names. Generally Python uses lists for arrays.

# create the name list
name_list = []
while True:
    name = raw_input("Enter your name (q to quit): ")
    if name.lower() == 'q':

# show the name_list contents
for name in name_list:
    print name

With numbers you can do something similar ...

# create the number list (int or float)
number_list = []
while True:
    number = input("Enter a number (-99 to quit): ")
    if number == -99:

# show the number_list contents
for number in number_list:
    print number

If you want to enter a fixed number of numbers, use a for loop ...

# create the number list (int or float)
number_list = []
for k in range(5):
    number = input("%d) Enter a number : " % (k+1))

# show the number_list
for number in number_list:
    print number

Edited by vegaseat: numbers


hmm..thanks for the reply. :)
i figured it out. :)

Edited by letlet_pogs: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.