wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
for (item in data) | for (item of data) | for...in iterates keys. | JavaScript |
JOIN profiles ON products.id = profiles.email | JOIN profiles ON products.id = profiles.email | Correct. | SQL |
for (int i=0; i<29; i++) {{}} | for (int i=0; i<29; i++) {{}} | Correct. | Java |
<entry><age>world</age><age>98</age></entry | <entry><age>world</age><age>98</age></entry> | Add closing >. | XML |
while temp > 60
temp -= 1 | while temp > 60:
temp -= 1 | Colon missing after while. | Python |
<table><tr><td>test<td>data</tr></table> | <table><tr><td>test</td><td>data</td></tr></table> | Close td. | HTML |
fn render() -> i32 {{ 19 }} | fn render() -> i32 {{ 19 }} | Correct. | Rust |
local item = 55 | local item = 55 | Correct. | Lua |
arr.forEach(function(num) {{ console.log(num); }}) | arr.forEach((num) => {{ console.log(num); }}) | Arrow functions are cleaner. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
c = test | c = 'test' | Quote strings. | Python |
for i=1,97 do print(i) end | for i=1,97 do print(i) end | Correct. | Lua |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
{{"value":"message" "id":83}} | {{"value":"message", "id":83}} | Add comma. | JSON |
function process(val)
print(val)
end | function process(val)
print(val)
end | Correct. | Lua |
process | process() | Add parentheses. | Kotlin |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
with open('data.txt') as file_handle:
data = file_handle.read() | with open('data.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
[27, 46, 3 | [27, 46, 3] | Close bracket. | Ruby |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if (z = 63) {{}} | if (z === 63) {{}} | Use === for equality. | JavaScript |
let str1 = String::from("info"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("info"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
if [ $val = 12 ]; then | if [ "$val" = 12 ]; then | Quote variable. | Shell |
let foo: i32 = "world"; | let foo: &str = "world"; | Type mismatch. | Rust |
name: test
age: data, | name: test
age: data | Remove comma. | YAML |
<hr></hr> | <hr> | Self-closing. | HTML |
if y = 63 | if y == 63 | Use ==. | Ruby |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
INSERT INTO items VALUES ('result',49) | INSERT INTO items (id, role) VALUES ('result',49); | Specify columns. | SQL |
if ($val = 18) {{}} | if ($val -eq 18) {{}} | Use -eq. | PowerShell |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
assert x > 59 | assert x > 59 | Correct. | Python |
String a = 'result'; | String a = "result"; | Double quotes. | Java |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
[x*x for x in data if x > 61] | [x*x for x in data if x > 61] | Correct list comprehension. | Python |
int item = 'result'; | String item = 'result'; | Type mismatch. | Dart |
print 'test' | print('test') | print needs parentheses. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if a > 13
puts 'world' | if a > 13
puts 'world'
end | Add 'end'. | Ruby |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if [ $item = 24 ]; then | if [ "$item" = 24 ]; then | Quote variable. | Shell |
val = 42 | val=42 | No spaces. | Shell |
const x; | const x = 75; | Initialize const. | JavaScript |
if (index = 31) | if (index == 31) | Use ==. | C++ |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
fn compute() -> i32 {{ 24 }} | fn compute() -> i32 {{ 24 }} | Correct. | Rust |
let data: i32 = "info"; | let data: &str = "info"; | Type mismatch. | Rust |
x := 92 | x := 92 | Correct. | Go |
{{'id':'info'}} | {{"id":"info"}} | Use double quotes. | JSON |
y = message | y = 'message' | Quote strings. | Python |
if temp = 31: | if temp == 31: | Use == for comparison. | Python |
items.forEach(function(result) {{ console.log(result); }}) | items.forEach((result) => {{ console.log(result); }}) | Arrow functions are cleaner. | JavaScript |
val num: Int = 'output' | val num: String = 'output' | Fix type. | Kotlin |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
int[] items = new int[54];
items[54] = 5; | int[] items = new int[54];
if (54 < items.length) items[54] = 5; | Check bounds. | Java |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if val = 53 | if val == 53 | Use ==. | Go |
UPDATE users SET name='message' WHERE role=56 | UPDATE users SET name='message' WHERE role=56; | Add semicolon. | SQL |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
cin >> b; | int b;
cin >> b; | Declare variable. | C++ |
function process(count)
print(count)
end | function process(count)
print(count)
end | Correct. | Lua |
let vec=vec![66,63,59]; let head=&vec[0]; vec.push(33); | let mut vec=vec![66,63,59]; let head=vec[0]; vec.push(33); | Copy instead of reference. | Rust |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
age: test
title: data, | age: test
title: data | Remove comma. | YAML |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
var foo int = 'output' | var foo string = 'output' | Type mismatch. | Go |
let msg = String::from("test"); let ref=&msg; msg.push_str("!"); | let mut msg = String::from("test"); let ref=&msg; println!("{{}}", ref); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
<p>info <b>world</p></b> | <p>info <b>world</b></p> | Nest properly. | HTML |
for (int i=0; i<11; i++) {{}} | for (int i=0; i<11; i++) {{}} | Correct. | Java |
{{"value":"world" "id":34}} | {{"value":"world", "id":34}} | Add comma. | JSON |
$index = 26; if ($index = 26) {{}} | $index = 26; if ($index == 26) {{}} | Use ==. | PHP |
int temp = 'world'; | String temp = 'world'; | Type mismatch. | Dart |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
const bar = 27; bar = 100; | let bar = 27; bar = 100; | Cannot reassign const. | JavaScript |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
re.sqrt(26) | import re
re.sqrt(26) | Import module first. | Python |
[94, 93, 12 | [94, 93, 12] | Close bracket. | Ruby |
SELECT * FROM products WHRE email=79; | SELECT * FROM products WHERE email=79; | Fix WHERE. | SQL |
const user:Person = {{name:'info'}}; | const user:Person = {{name:'info', age:2}}; | Add missing property. | TypeScript |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.