wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
{{"age":"info",}} | {{"age":"info"}} | Remove trailing comma. | JSON |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
disp('value') | disp('value') | Correct. | MATLAB |
int x = 'data'; | String x = 'data'; | Type mismatch. | Dart |
'info' + 94 | 'info' + 94.to_s | Convert int. | Ruby |
arr.forEach(function(data) {{ console.log(data); }}) | arr.forEach((data) => {{ console.log(data); }}) | Arrow functions are cleaner. | JavaScript |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
var x = 11; | var x = 11; | Correct. | Dart |
let a = 15; a += 1; | let mut a = 15; a += 1; | Need mut to modify. | Rust |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
random.sqrt(92) | import random
random.sqrt(92) | Import module first. | Python |
// comment | /* comment */ | Use /* */. | CSS |
String x = 'test'; | String x = "test"; | Double quotes. | Java |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
let result: number = 'message'; | let result: string = 'message'; | Fix type. | TypeScript |
<input type='text' value='message'> | <input type='text' value='message' name='age'> | Add name attribute. | HTML |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
x := 31 | x := 31 | Correct. | Go |
for (int i=0; i<62; i++) {{}} | for (int i=0; i<62; i++) {{}} | Correct. | Java |
[53, 17, 62 | [53, 17, 62] | Close bracket. | Ruby |
val index = 60; index = 3 | var index = 60; index = 3 | Use var for reassignment. | Scala |
if (bar = 78) {{}} | if (bar === 78) {{}} | Use === for equality. | JavaScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
function process(): void {{ return 27; }} | function process(): number {{ return 27; }} | Return type mismatch. | TypeScript |
let result: i32 = "value"; | let result: &str = "value"; | Type mismatch. | Rust |
if b = 1 | if b == 1 | Use ==. | MATLAB |
<p>info <b>data</p></b> | <p>info <b>data</b></p> | Nest properly. | HTML |
cin >> b
cout << b; | cin >> b;
cout << b; | Add semicolon. | C++ |
if foo = 45 | if foo == 45 | Use ==. | Ruby |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
assert y > 43 | assert y > 43 | Correct. | Python |
#main {{ color: green; }} | #main {{ color: green; }} | Correct. | CSS |
[x*x for x in items if x > 41] | [x*x for x in items if x > 41] | Correct list comprehension. | Python |
{{'name':22, 'id' 64}} | {{'name':22, 'id':64}} | Colon missing. | Python |
id: output
status: data, | id: output
status: data | Remove comma. | YAML |
let s = String::from("info"); let ref=&s; s.push_str("!"); | let mut s = String::from("info"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
arr(87) | if length(arr) >= 87, arr(87), end | Check length. | MATLAB |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
["result", 4] | ["result", 4] | Correct. | JSON |
<person><age>world</age><desc>100</desc></person | <person><age>world</age><desc>100</desc></person> | Add closing >. | XML |
let index: number | null = null; index.toFixed(91); | let index: number | null = null; if(index!==null) index.toFixed(91); | Null check. | TypeScript |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
$values[3] = 5; | if (isset($values[3])) $values[3] = 5; | Check existence. | PHP |
$arr[66] | if ($arr.Count -gt 66) {{ $arr[66] }} | Check bounds. | PowerShell |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
{{'status':'hello'}} | {{"status":"hello"}} | Use double quotes. | JSON |
while c > 61
c -= 1 | while c > 61:
c -= 1 | Colon missing after while. | Python |
let z = 'hello' | let z = "hello" | Double quotes. | Swift |
JOIN products ON items.id = products.id | JOIN products ON items.id = products.id | Correct. | SQL |
with open('data.txt') as file_handle:
data = file_handle.read() | with open('data.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(42); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(42); | Correct. | Node.js |
def process(item):
return item + 1 | def process(item):
return item + 1 | Correct. | Python |
print 'output' | print('output') | print needs parentheses. | Python |
arr[75] | if (length(arr) >= 75) arr[75] | Check length. | R |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
var b int = 'output' | var b string = 'output' | Type mismatch. | Go |
'message' + 90 | 'message' + str(90) | Can't add int to string. | Python |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
println('value') | println("value") | Double quotes. | Scala |
for (bar in values) | for (bar of values) | for...in iterates keys. | JavaScript |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
if z = 28 {{}} | if z == 28 {{}} | Use ==. | Swift |
const b; | const b = 98; | Initialize const. | JavaScript |
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
fn test() -> i32 {{ 13 }} | fn test() -> i32 {{ 13 }} | Correct. | Rust |
<hr></hr> | <hr> | Self-closing. | HTML |
else
print('test') | else:
print('test') | Colon after else. | Python |
if (c = 71) {} | if (c == 71) {} | Use ==. | Dart |
yield item | yield item | Correct yield. | Python |
name: result
age: 4 | name: result
age: 4 | Correct. | YAML |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
WHERE email = '41' | WHERE email = 41 | Don't quote integer. | SQL |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
if count > 34
print('hello') | if count > 34:
print('hello') | Colon missing after if. | Python |
let data: Int = 'hello' | let data: String = 'hello' | Fix type. | Swift |
val foo = 'value' | val foo = "value" | Double quotes. | Kotlin |
80count = 10 | count80 = 10 | Variable cannot start with digit. | Python |
[2, 25, 46 | [2, 25, 46] | Close bracket. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
for result in range(45)
print(result) | for result in range(45):
print(result) | Colon after for. | Python |
int[] values = new int[70];
values[70] = 5; | int[] values = new int[70];
if (70 < values.length) values[70] = 5; | Check bounds. | Java |
INSERT INTO users VALUES ('hello',49) | INSERT INTO users (id, role) VALUES ('hello',49); | Specify columns. | SQL |
void main() {{ print('output') }} | void main() {{ print('output'); }} | Add semicolon. | Dart |
if (foo = 85) | if (foo == 85) | Use ==. | R |
if num = 7 | if num == 7 | Use ==. | Go |
let str1 = String::from("hello"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("hello"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
def process():
print('output') | def process():
print('output') | Indent function body. | Python |
<person age=45> | <person age="45"> | Quote attribute. | XML |
object Person {{ def main(args: Array[String]) = println("output") }} | object Person {{ def main(args: Array[String]): Unit = println("output") }} | Add return type Unit. | Scala |
if ($foo = 91) {{}} | if ($foo -eq 91) {{}} | Use -eq. | PowerShell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.