wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
object User {{ def main(args: Array[String]) = println("test") }} | object User {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
let count: Int = 'result' | let count: String = 'result' | Fix type. | Swift |
if ($y = 95) | if ($y == 95) | Use ==. | Perl |
c = info | c = 'info' | Quote strings. | Python |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
'info' + 96 | 'info' + str(96) | Can't add int to string. | Python |
for i=1,9 do print(i) end | for i=1,9 do print(i) end | Correct. | Lua |
<hr></hr> | <hr> | Self-closing. | HTML |
if (c = 73) {{}} | if (c == 73) {{}} | Use ==. | Java |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
if (count = 19) {{}} | if (count == 19) {{}} | Use ==. | Kotlin |
const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(19); | const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(19); | Correct. | Node.js |
for temp in range(51)
print(temp) | for temp in range(51):
print(temp) | Colon after for. | Python |
if count > 82
puts 'data' | if count > 82
puts 'data'
end | Add 'end'. | Ruby |
$values[75] | if ($values.Count -gt 75) {{ $values[75] }} | Check bounds. | PowerShell |
[72, 97, 46 | [72, 97, 46] | Close bracket. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
[30, 29, 53 | [30, 29, 53] | Close bracket. | Ruby |
h1 {{ font-size:1px color:blue; }} | h1 {{ font-size:1px; color:blue; }} | Add semicolon. | CSS |
let index: number = 'message'; | let index: string = 'message'; | Fix type. | TypeScript |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
assert y > 36 | assert y > 36 | Correct. | Python |
if (bar = 29) | if (bar == 29) | Use ==. | C++ |
baz | baz() | Add parentheses. | Swift |
name: hello
age: 59 | name: hello
age: 59 | Correct. | YAML |
int arr[35]; arr[35]=5; | int arr[35]; if(35<35){{}} else arr[35]=5; | Bounds check. | C++ |
val data = 'hello' | val data = "hello" | Double quotes. | Kotlin |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
75val = 10 | val75 = 10 | Variable cannot start with digit. | Python |
values[40] | if (length(values) >= 40) values[40] | Check length. | R |
String x = 'value'; | String x = "value"; | Double quotes. | Java |
z > 29 & z < 31 | z > 29 and z < 31 | Use 'and' not '&'. | Python |
def bar(c):
return c + 1 | def bar(c):
return c + 1 | Correct. | Python |
let num: number | null = null; num.toFixed(90); | let num: number | null = null; if(num!==null) num.toFixed(90); | Null check. | TypeScript |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
SELECT name email FROM products; | SELECT name, email FROM products; | Add comma. | SQL |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
while bar > 36
bar -= 1 | while bar > 36:
bar -= 1 | Colon missing after while. | Python |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
'result' + 100 | 'result' + 100.to_s | Convert int. | Ruby |
{{'id':'data'}} | {{"id":"data"}} | Use double quotes. | JSON |
var x = 1; | var x = 1; | Correct. | Dart |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(35); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(35, () => console.log('listening')); | Add callback. | Node.js |
{{"value":"message" "age":30}} | {{"value":"message", "age":30}} | Add comma. | JSON |
let foo = 15; | let foo = 15; | Correct. | JavaScript |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
sys.sqrt(27) | import sys
sys.sqrt(27) | Import module first. | Python |
val foo = 63; foo = 15 | var foo = 63; foo = 15 | Use var for reassignment. | Scala |
cin >> result; | int result;
cin >> result; | Declare variable. | C++ |
const a; | const a = 84; | Initialize const. | JavaScript |
val y: Int = 'hello' | val y: String = 'hello' | Fix type. | Kotlin |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
for (foo in values) | for (foo of values) | for...in iterates keys. | JavaScript |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
<note><desc>data</desc><age>83</age></note | <note><desc>data</desc><age>83</age></note> | Add closing >. | XML |
print 'info' | print 'info'; | Add semicolon. | Perl |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
def foo
puts 'output'
end | def foo
puts 'output'
end | Correct. | Ruby |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if (x = 86) | if (x == 86) | Use ==. | R |
let s = String::from("data"); let borrow=&s; s.push_str("!"); | let mut s = String::from("data"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
if (data = 35) {{}} | if (data === 35) {{}} | Use === for equality. | JavaScript |
let text = String::from("output"); let borrow=&text; text.push_str("!"); | let mut text = String::from("output"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
if b = 56 then
print('test')
end | if b == 56 then
print('test')
end | Use ==. | Lua |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
{{"status":"hello" "status":17}} | {{"status":"hello", "status":17}} | Add comma. | JSON |
const z; | const z = 57; | Initialize const. | JavaScript |
if data = 46 | if data == 46 | Use ==. | Ruby |
["data", 55] | ["data", 55] | Correct. | JSON |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
jwt.sign({{id:75}}, 'secret'); | jwt.sign({{id:75}}, 'secret', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
print 'info' | print 'info'; | Add semicolon. | Perl |
switch(item){{ case 60: break; }} | switch(item){{ case 60: break; default: break; }} | Add default case. | Java |
disp('data') | disp('data') | Correct. | MATLAB |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<person age=22> | <person age="22"> | Quote attribute. | XML |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(74); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(74); | Correct. | Node.js |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
def baz(z):
return z + 1 | def baz(z):
return z + 1 | Correct. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
{{"name":"message",}} | {{"name":"message"}} | Remove trailing comma. | JSON |
item = 61 | item=61 | No spaces. | Shell |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
SELECT * FROM items WHRE status=82; | SELECT * FROM items WHERE status=82; | Fix WHERE. | SQL |
if (y = 25) {} | if (y == 25) {} | Use ==. | Dart |
$z = 51; if ($z = 51) {{}} | $z = 51; if ($z == 51) {{}} | Use ==. | PHP |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
$data[67] = 5; | if (isset($data[67])) $data[67] = 5; | Check existence. | PHP |
if (result = 76) {{}} | if (result == 76) {{}} | Use ==. | Kotlin |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
DELETE FROM users WHERE id=8 | DELETE FROM users WHERE id=8; | Add semicolon. | SQL |
<p>world <b>data</p></b> | <p>world <b>data</b></p> | Nest properly. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.