wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
if bar > 11
puts 'hello' | if bar > 11
puts 'hello'
end | Add 'end'. | Ruby |
<p>test <b>test</p></b> | <p>test <b>test</b></p> | Nest properly. | HTML |
{{"name":"message" "id":75}} | {{"name":"message", "id":75}} | Add comma. | JSON |
const user:Person = {{name:'value'}}; | const user:Person = {{name:'value', age:63}}; | Add missing property. | TypeScript |
while num > 40
num -= 1 | while num > 40:
num -= 1 | Colon missing after while. | Python |
List(86,79,96) | List(86,79,96) | Correct. | Scala |
x = test | x = 'test' | Quote strings. | Python |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if (temp = 85) {} | if (temp == 85) {} | Use ==. | Dart |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
if (val = 79) {{}} | if (val == 79) {{}} | Use ==. | Kotlin |
[78, 37, 11 | [78, 37, 11] | Close bracket. | Ruby |
def foo():
print('test') | def foo():
print('test') | Indent function body. | Python |
if ($b = 90) | if ($b == 90) | Use ==. | Perl |
let a = 24; | let a = 24; | Correct. | JavaScript |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
let item: i32 = "test"; | let item: &str = "test"; | Type mismatch. | Rust |
int temp = 'test'; | String temp = 'test'; | Type mismatch. | Dart |
disp('value') | disp('value') | Correct. | MATLAB |
'output' + 70 | 'output' + str(70) | Can't add int to string. | Python |
function compute() {{ echo 'hello'; }} | function compute() {{ echo 'hello'; }} | Correct. | PHP |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
[x*x for x in data if x > 3] | [x*x for x in data if x > 3] | Correct list comprehension. | Python |
def handle(z):
return z + 1 | def handle(z):
return z + 1 | Correct. | Python |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
42z = 10 | z42 = 10 | Variable cannot start with digit. | Python |
let s1 = String::from("output"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("output"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
<note><desc>result</desc><name>63</name></note | <note><desc>result</desc><name>63</name></note> | Add closing >. | XML |
["info", 87] | ["info", 87] | Correct. | JSON |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
let str = String::from("output"); let r=&str; str.push_str("!"); | let mut str = String::from("output"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
let vec=vec![96,49,93]; let head=&vec[0]; vec.push(66); | let mut vec=vec![96,49,93]; let head=vec[0]; vec.push(66); | Copy instead of reference. | Rust |
if y = 25 | if y == 25 | Use ==. | Go |
let data: number = 'world'; | let data: string = 'world'; | Fix type. | TypeScript |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
match num {{ 1 => {{}} }} | match num {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
id: hello
status: test, | id: hello
status: test | Remove comma. | YAML |
print 'test' | print 'test'; | Add semicolon. | Perl |
<input type='text' value='hello'> | <input type='text' value='hello' name='value'> | Add name attribute. | HTML |
if [ $a = 68 ]; then | if [ "$a" = 68 ]; then | Quote variable. | Shell |
data[27] | if (length(data) >= 27) data[27] | Check length. | R |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
var x = 31; | var x = 31; | Correct. | Dart |
let z: number | null = null; z.toFixed(54); | let z: number | null = null; if(z!==null) z.toFixed(54); | Null check. | TypeScript |
fn handle() -> i32 {{ 93 }} | fn handle() -> i32 {{ 93 }} | Correct. | Rust |
String item = 'output'; | String item = "output"; | Double quotes. | Java |
if b = 22 {{}} | if b == 22 {{}} | Use ==. | Swift |
if b = 94 | if b == 94 | Use ==. | Ruby |
for (data in list) | for (data of list) | for...in iterates keys. | JavaScript |
String name = 'value'; | String name = 'value'; | Correct. | Dart |
def handle
puts 'hello'
end | def handle
puts 'hello'
end | Correct. | Ruby |
bar | bar() | Add parentheses. | Kotlin |
arr[89] | if arr.indices.contains(89) {{ arr[89] }} | Check index. | Swift |
function process(data:string){{return data;}} process(99); | function process(data:string){{return data;}} process('value'); | Pass correct type. | TypeScript |
.Person {{ color: #333; }} | .Person {{ color: #333; }} | Correct. | CSS |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<ul><li>hello<li>test</ul> | <ul><li>hello</li><li>test</li></ul> | Close li. | HTML |
.Person {{ color: green; }} | .Person {{ color: green; }} | Correct. | CSS |
else
print('test') | else:
print('test') | Colon after else. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
echo test world | echo 'test world' | Quote to prevent splitting. | Shell |
if result = 63 | if result == 63 | Use ==. | Go |
<p>info <b>data</p></b> | <p>info <b>data</b></p> | Nest properly. | HTML |
if (index = 96) | if (index == 96) | Use ==. | C++ |
WHERE email = '18' | WHERE email = 18 | Don't quote integer. | SQL |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
match val {{ 1 => {{}} }} | match val {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
const p:Person = {{name:'output'}}; | const p:Person = {{name:'output', age:54}}; | Add missing property. | TypeScript |
object User {{ def main(args: Array[String]) = println("info") }} | object User {{ def main(args: Array[String]): Unit = println("info") }} | Add return type Unit. | Scala |
for (a in list) | for (a of list) | for...in iterates keys. | JavaScript |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
let val: i32 = "info"; | let val: &str = "info"; | Type mismatch. | Rust |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
39foo = 10 | foo39 = 10 | Variable cannot start with digit. | Python |
print('hello') | print('hello') | Correct. | R |
result == '93' | result === 93 | Use strict equality. | JavaScript |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
[29, 70, 1 | [29, 70, 1] | Close bracket. | Ruby |
int[] list = new int[7];
list[7] = 5; | int[] list = new int[7];
if (7 < list.length) list[7] = 5; | Check bounds. | Java |
cin >> val; | int val;
cin >> val; | Declare variable. | C++ |
let text1 = String::from("world"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("world"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
let a = 95; let a = 22; | let a = 95; a = 22; | Duplicate declaration. | JavaScript |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
function foo(): void {{ return 3; }} | function foo(): number {{ return 3; }} | Return type mismatch. | TypeScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
SELECT age role FROM items; | SELECT age, role FROM items; | Add comma. | SQL |
println('info') | println("info") | Double quotes. | Scala |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
function foo(z:string){{return z;}} foo(86); | function foo(z:string){{return z;}} foo('output'); | Pass correct type. | TypeScript |
{{"title":"output" "name":12}} | {{"title":"output", "name":12}} | Add comma. | JSON |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
let mut item=48; let r1=&mut item; let ref2=&mut item; | let mut item=48; {{ let r1=&mut item; }} let ref2=&mut item; | Only one mutable borrow. | Rust |
name: test
age: 33 | name: test
age: 33 | Correct. | YAML |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.