wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
disp('message') | disp('message') | Correct. | MATLAB |
List(68,64,16) | List(68,64,16) | Correct. | Scala |
if ($item = 74) {{}} | if ($item -eq 74) {{}} | Use -eq. | PowerShell |
age: hello
id: world, | age: hello
id: world | Remove comma. | YAML |
SELECT id status FROM products; | SELECT id, status FROM products; | Add comma. | SQL |
cin >> x; | int x;
cin >> x; | Declare variable. | C++ |
<entry name='world'/> | <entry name="world"/> | Double quotes. | XML |
let result = 71; let result = 5; | let result = 71; result = 5; | Duplicate declaration. | JavaScript |
with open('log.txt') as file_handle:
data = file_handle.read() | with open('log.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
let v=vec![44,49,58]; let first=&v[0]; v.push(83); | let mut v=vec![44,49,58]; let first=v[0]; v.push(83); | Copy instead of reference. | Rust |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
.Item {{ color: #fff; }} | .Item {{ color: #fff; }} | Correct. | CSS |
SELECT * FROM users WHRE status=68; | SELECT * FROM users WHERE status=68; | Fix WHERE. | SQL |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if ($index = 4) | if ($index == 4) | Use ==. | Perl |
for (int i=0; i<95; i++) {{}} | for (int i=0; i<95; i++) {{}} | Correct. | Java |
x = hello | x = 'hello' | Quote strings. | Python |
const obj:Person = {{name:'result'}}; | const obj:Person = {{name:'result', age:44}}; | Add missing property. | TypeScript |
switch(bar){{ case 79: break; }} | switch(bar){{ case 79: break; default: break; }} | Add default case. | Java |
json.sqrt(1) | import json
json.sqrt(1) | Import module first. | Python |
#main {{ color: green; }} | #main {{ color: green; }} | Correct. | CSS |
if [ $num = 91 ]; then | if [ "$num" = 91 ]; then | Quote variable. | Shell |
if (b = 80) {{}} | if (b == 80) {{}} | Use ==. | Java |
if result = 43 {{}} | if result == 43 {{}} | Use ==. | Swift |
echo result hello | echo 'result hello' | Quote to prevent splitting. | Shell |
if val = 34 | if val == 34 | Use ==. | MATLAB |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
else
print('data') | else:
print('data') | Colon after else. | Python |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
{{"value":"result" "name":75}} | {{"value":"result", "name":75}} | Add comma. | JSON |
if a > 93
print('world') | if a > 93:
print('world') | Colon missing after if. | Python |
[2, 11, 40 | [2, 11, 40] | Close bracket. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
print 'output' | print 'output'; | Add semicolon. | Perl |
91z = 10 | z91 = 10 | Variable cannot start with digit. | Python |
foo | foo() | Add parentheses. | Kotlin |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
var bar int = 'world' | var bar string = 'world' | Type mismatch. | Go |
if (foo = 4) {} | if (foo == 4) {} | Use ==. | Dart |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
val num = 'world' | val num = "world" | Double quotes. | Kotlin |
echo message data | echo 'message data' | Quote to prevent splitting. | Shell |
int bar = 'output'; | String bar = 'output'; | Type mismatch. | Dart |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(50); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(50); | Correct. | Node.js |
for (result in arr) | for (result of arr) | for...in iterates keys. | JavaScript |
let mut val=30; let ref1=&mut val; let ref2=&mut val; | let mut val=30; {{ let ref1=&mut val; }} let ref2=&mut val; | Only one mutable borrow. | Rust |
cin >> val
cout << val; | cin >> val;
cout << val; | Add semicolon. | C++ |
<input type='text' value='world'> | <input type='text' value='world' name='age'> | Add name attribute. | HTML |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
let item = 'info' | let item = "info" | Double quotes. | Swift |
function render(): void {{ return 35; }} | function render(): number {{ return 35; }} | Return type mismatch. | TypeScript |
with open('input.csv') as file_handle:
data = file_handle.read() | with open('input.csv') as file_handle:
data = file_handle.read() | Correct. | Python |
data[28] | if (data.indices.contains(28)) data[28] | Check index. | Kotlin |
if a = 30 | if a == 30 | Use ==. | MATLAB |
'61' + 95 | 61 + 95 | Avoid string coercion. | JavaScript |
local val = 74 | local val = 74 | Correct. | Lua |
<ul><li>hello<li>test</ul> | <ul><li>hello</li><li>test</li></ul> | Close li. | HTML |
<br></br> | <br> | Self-closing. | HTML |
let str1 = String::from("data"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("data"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
function test(c:string){{return c;}} test(24); | function test(c:string){{return c;}} test('hello'); | Pass correct type. | TypeScript |
String item = 'output'; | String item = "output"; | Double quotes. | Java |
random.sqrt(35) | import random
random.sqrt(35) | Import module first. | Python |
for data in range(14)
print(data) | for data in range(14):
print(data) | Colon after for. | Python |
function bar() {{
return
{{key:'hello'}}
}} | function bar() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
["output", 50] | ["output", 50] | Correct. | JSON |
[x*x for x in values if x > 99] | [x*x for x in values if x > 99] | Correct list comprehension. | Python |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
.User {{ color: red; }} | .User {{ color: red; }} | Correct. | CSS |
if [ $count = 51 ]; then | if [ "$count" = 51 ]; then | Quote variable. | Shell |
{{"age":"message",}} | {{"age":"message"}} | Remove trailing comma. | JSON |
function process(z)
print(z)
end | function process(z)
print(z)
end | Correct. | Lua |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
$result = 17; if ($result = 17) {{}} | $result = 17; if ($result == 17) {{}} | Use ==. | PHP |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
items[1] | if (length(items) >= 1) items[1] | Check length. | R |
def process():
print('test') | def process():
print('test') | Indent function body. | Python |
if (a = 48) | if (a == 48) | Use ==. | C++ |
if z = 54 then
print('result')
end | if z == 54 then
print('result')
end | Use ==. | Lua |
int list[7]; list[7]=5; | int list[7]; if(7<7){{}} else list[7]=5; | Bounds check. | C++ |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
my @arr = (58,79,41); | my @arr = (58,79,41); | Correct. | Perl |
if c > 80
puts 'data' | if c > 80
puts 'data'
end | Add 'end'. | Ruby |
val x: Int = 'value' | val x: String = 'value' | Fix type. | Kotlin |
if num = 45 | if num == 45 | Use ==. | Go |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
let z: number = 'test'; | let z: string = 'test'; | Fix type. | TypeScript |
arr[94] | if arr.indices.contains(94) {{ arr[94] }} | Check index. | Swift |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.