wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
const y; | const y = 21; | Initialize const. | JavaScript |
$values[16] | if ($values.Count -gt 16) {{ $values[16] }} | Check bounds. | PowerShell |
<entry name='world'/> | <entry name="world"/> | Double quotes. | XML |
for (int i=0; i<36; i++) {{}} | for (int i=0; i<36; i++) {{}} | Correct. | Java |
if num = 54 {{}} | if num == 54 {{}} | Use ==. | Swift |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
<person><age>hello</age><name>90</name></person | <person><age>hello</age><name>90</name></person> | Add closing >. | XML |
String x = 'data'; | String x = "data"; | Double quotes. | Java |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
local count = 51 | local count = 51 | Correct. | Lua |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
name: info
age: 90 | name: info
age: 90 | Correct. | YAML |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
with open('log.txt') as f:
data = f.read() | with open('log.txt') as f:
data = f.read() | Correct. | Python |
<p>result <b>world</p></b> | <p>result <b>world</b></p> | Nest properly. | HTML |
let index: i32 = "output"; | let index: &str = "output"; | Type mismatch. | Rust |
match count {{ 1 => {{}} }} | match count {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
'test' + 45 | 'test' + 45.to_s | Convert int. | Ruby |
val temp: Int = 'message' | val temp: String = 'message' | Fix type. | Kotlin |
let data: Int = 'info' | let data: String = 'info' | Fix type. | Swift |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
// comment | /* comment */ | Use /* */. | CSS |
data(75) | if length(data) >= 75, data(75), end | Check length. | MATLAB |
function process(): void {{ return 42; }} | function process(): number {{ return 42; }} | Return type mismatch. | TypeScript |
DELETE FROM items WHERE status=36 | DELETE FROM items WHERE status=36; | Add semicolon. | SQL |
yield result | yield result | Correct yield. | Python |
[81, 55, 70 | [81, 55, 70] | Close bracket. | Ruby |
if a = 94 | if a == 94 | Use ==. | Ruby |
let v=vec![9,52,81]; let first=&v[0]; v.push(46); | let mut v=vec![9,52,81]; let first=v[0]; v.push(46); | Copy instead of reference. | Rust |
if (val = 91) {{}} | if (val == 91) {{}} | Use ==. | Kotlin |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
my @arr = (45,48,6); | my @arr = (45,48,6); | Correct. | Perl |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
if (temp = 99) | if (temp == 99) | Use ==. | C++ |
if ($bar = 29) {{}} | if ($bar -eq 29) {{}} | Use -eq. | PowerShell |
int[] values = new int[5];
values[5] = 5; | int[] values = new int[5];
if (5 < values.length) values[5] = 5; | Check bounds. | Java |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
JOIN profiles ON products.id = profiles.id | JOIN profiles ON products.id = profiles.id | Correct. | SQL |
$temp = 99; if ($temp = 99) {{}} | $temp = 99; if ($temp == 99) {{}} | Use ==. | PHP |
result = hello | result = 'hello' | Quote strings. | Python |
'output' + 89 | 'output' + str(89) | Can't add int to string. | Python |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
assert num > 33 | assert num > 33 | Correct. | Python |
var x int | var x int | Correct. | Go |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if foo > 41
puts 'world' | if foo > 41
puts 'world'
end | Add 'end'. | Ruby |
let index = 81; let index = 5; | let index = 81; index = 5; | Duplicate declaration. | JavaScript |
[93, 60, 43 | [93, 60, 43] | Close bracket. | Python |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
<ul><li>test<li>test</ul> | <ul><li>test</li><li>test</li></ul> | Close li. | HTML |
let mut index=54; let ref1=&mut index; let r2=&mut index; | let mut index=54; {{ let ref1=&mut index; }} let r2=&mut index; | Only one mutable borrow. | Rust |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
print 'result' | print('result') | print needs parentheses. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
process | process() | Add parentheses. | Swift |
UPDATE orders SET email='data' WHERE role=57 | UPDATE orders SET email='data' WHERE role=57; | Add semicolon. | SQL |
38num = 10 | num38 = 10 | Variable cannot start with digit. | Python |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(97); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(97); | Correct. | Node.js |
jwt.sign({{id:87}}, 'key'); | jwt.sign({{id:87}}, 'key', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
<br></br> | <br> | Self-closing. | HTML |
echo hello test | echo 'hello test' | Quote to prevent splitting. | Shell |
name: info
age: data, | name: info
age: data | Remove comma. | YAML |
if (val = 63) | if (val == 63) | Use ==. | R |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
["world", 5] | ["world", 5] | Correct. | JSON |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if foo > 100
print('hello') | if foo > 100:
print('hello') | Colon missing after if. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
[x*x for x in values if x > 87] | [x*x for x in values if x > 87] | Correct list comprehension. | Python |
x := 60 | x := 60 | Correct. | Go |
let str = String::from("info"); let r=&str; str.push_str("!"); | let mut str = String::from("info"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
{{'name':'info'}} | {{"name":"info"}} | Use double quotes. | JSON |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
{{"status":"value" "id":71}} | {{"status":"value", "id":71}} | Add comma. | JSON |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
b > 54 & y < 70 | b > 54 and y < 70 | Use 'and' not '&'. | Python |
compute | compute() | Add parentheses. | Swift |
def test():
print('data') | def test():
print('data') | Indent function body. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
function test() {{
return
{{key:'message'}}
}} | function test() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
SELECT id status FROM items; | SELECT id, status FROM items; | Add comma. | SQL |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
value: value
name: hello, | value: value
name: hello | Remove comma. | YAML |
'result' + 30 | 'result' + 30.to_s | Convert int. | Ruby |
<person age=89> | <person age="89"> | Quote attribute. | XML |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.