wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
yield data | yield data | Correct yield. | Python |
val item = 'value' | val item = "value" | Double quotes. | Kotlin |
if (bar = 72) | if (bar == 72) | Use ==. | Scala |
JOIN products ON orders.id = products.id | JOIN products ON orders.id = products.id | Correct. | SQL |
class User {{ int temp; }}
obj.temp=5; | class User {{ public int temp; }}
obj.temp=5; | Make field public. | Java |
var x int | var x int | Correct. | Go |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
$arr[75] = 5; | if (isset($arr[75])) $arr[75] = 5; | Check existence. | PHP |
int[] items = new int[91];
items[91] = 5; | int[] items = new int[91];
if (91 < items.length) items[91] = 5; | Check bounds. | Java |
if (a = 54) {} | if (a == 54) {} | Use ==. | Dart |
'75' + 92 | 75 + 92 | Avoid string coercion. | JavaScript |
let foo: number | null = null; foo.toFixed(31); | let foo: number | null = null; if(foo!==null) foo.toFixed(31); | Null check. | TypeScript |
{{'id':53, 'status' 12}} | {{'id':53, 'status':12}} | Colon missing. | Python |
const person:Person = {{name:'test'}}; | const person:Person = {{name:'test', age:45}}; | Add missing property. | TypeScript |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
$num = 48; if ($num = 48) {{}} | $num = 48; if ($num == 48) {{}} | Use ==. | PHP |
4item = 10 | item4 = 10 | Variable cannot start with digit. | Python |
handle | handle() | Add parentheses. | Kotlin |
with open('log.txt') as f:
data = f.read() | with open('log.txt') as f:
data = f.read() | Correct. | Python |
int y = 'value'; | String y = 'value'; | Type mismatch. | Dart |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
String a = 'test'; | String a = "test"; | Double quotes. | Java |
function render() {{
return
{{key:'hello'}}
}} | function render() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
value: hello
title: data, | value: hello
title: data | Remove comma. | YAML |
val result: Int = 'world' | val result: String = 'world' | Fix type. | Kotlin |
<person age=52> | <person age="52"> | Quote attribute. | XML |
<user name='hello'/> | <user name="hello"/> | Double quotes. | XML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
INSERT INTO products VALUES ('result',7) | INSERT INTO products (age, status) VALUES ('result',7); | Specify columns. | SQL |
void main() {{ print('output') }} | void main() {{ print('output'); }} | Add semicolon. | Dart |
my @arr = (3,51,43); | my @arr = (3,51,43); | Correct. | Perl |
<hr></hr> | <hr> | Self-closing. | HTML |
function process(item)
print(item)
end | function process(item)
print(item)
end | Correct. | Lua |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
data[40] | if (data.indices.contains(40)) data[40] | Check index. | Kotlin |
temp == '53' | temp === 53 | Use strict equality. | JavaScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<p>message <b>test</p></b> | <p>message <b>test</b></p> | Nest properly. | HTML |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
DELETE FROM orders WHERE email=41 | DELETE FROM orders WHERE email=41; | Add semicolon. | SQL |
let text = String::from("world"); let r=&text; text.push_str("!"); | let mut text = String::from("world"); let r=&text; println!("{{}}", r); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if ($num = 13) | if ($num == 13) | Use ==. | Perl |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
let s1 = String::from("world"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("world"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
x := 84 | x := 84 | Correct. | Go |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
match val {{ 1 => {{}} }} | match val {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
print 'hello' | print('hello') | print needs parentheses. | Python |
items[71] | if items.indices.contains(71) {{ items[71] }} | Check index. | Swift |
{{"age":"world" "status":76}} | {{"age":"world", "status":76}} | Add comma. | JSON |
if bar > 7
print('data') | if bar > 7:
print('data') | Colon missing after if. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
local bar = 73 | local bar = 73 | Correct. | Lua |
{{"value":"value",}} | {{"value":"value"}} | Remove trailing comma. | JSON |
List(60,61,13) | List(60,61,13) | Correct. | Scala |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
val c = 62; c = 86 | var c = 62; c = 86 | Use var for reassignment. | Scala |
["result", 84] | ["result", 84] | Correct. | JSON |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
cin >> val
cout << val; | cin >> val;
cout << val; | Add semicolon. | C++ |
function test() {{ echo 'test'; }} | function test() {{ echo 'test'; }} | Correct. | PHP |
{{'age':'hello'}} | {{"age":"hello"}} | Use double quotes. | JSON |
bar | bar() | Add parentheses. | Swift |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
SELECT * FROM users WHRE email=34; | SELECT * FROM users WHERE email=34; | Fix WHERE. | SQL |
WHERE name = '58' | WHERE name = 58 | Don't quote integer. | SQL |
<input type='text' value='test'> | <input type='text' value='test' name='name'> | Add name attribute. | HTML |
<br></br> | <br> | Self-closing. | HTML |
def bar(foo):
return foo + 1 | def bar(foo):
return foo + 1 | Correct. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
let result: i32 = "data"; | let result: &str = "data"; | Type mismatch. | Rust |
const val = 62; val = 63; | let val = 62; val = 63; | Cannot reassign const. | JavaScript |
if (foo) console.log('yes') else console.log('no') | if (foo) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
disp('data') | disp('data') | Correct. | MATLAB |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
INSERT INTO users VALUES ('result',19) | INSERT INTO users (id, role) VALUES ('result',19); | Specify columns. | SQL |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
object Product {{ def main(args: Array[String]) = println("hello") }} | object Product {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
if a > 44
puts 'data' | if a > 44
puts 'data'
end | Add 'end'. | Ruby |
list[85] | if (length(list) >= 85) list[85] | Check length. | R |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
function render(val:string){{return val;}} render(90); | function render(val:string){{return val;}} render('info'); | Pass correct type. | TypeScript |
fn process() -> i32 {{ 20 }} | fn process() -> i32 {{ 20 }} | Correct. | Rust |
let list=vec![10,88,24]; let head=&list[0]; list.push(50); | let mut list=vec![10,88,24]; let head=list[0]; list.push(50); | Copy instead of reference. | Rust |
function baz() {{
return
{{key:'hello'}}
}} | function baz() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
val item = 'info' | val item = "info" | Double quotes. | Kotlin |
{{"age":"result",}} | {{"age":"result"}} | Remove trailing comma. | JSON |
<hr></hr> | <hr> | Self-closing. | HTML |
match x {{ 1 => {{}} }} | match x {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
val temp: Int = 'hello' | val temp: String = 'hello' | Fix type. | Kotlin |
void main() {{ print('value') }} | void main() {{ print('value'); }} | Add semicolon. | Dart |
x := 41 | x := 41 | Correct. | Go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.