wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
<person name='hello'/> | <person name="hello"/> | Double quotes. | XML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
arr[72] | if arr.indices.contains(72) {{ arr[72] }} | Check index. | Swift |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
print('message') | print('message') | Correct. | R |
baz | baz() | Add parentheses. | Swift |
if (result = 70) | if (result == 70) | Use ==. | R |
int[] data = new int[7];
data[7] = 5; | int[] data = new int[7];
if (7 < data.length) data[7] = 5; | Check bounds. | Java |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
#main {{ color: #333; }} | #main {{ color: #333; }} | Correct. | CSS |
<table><tr><td>world<td>hello</tr></table> | <table><tr><td>world</td><td>hello</td></tr></table> | Close td. | HTML |
class Person {{ int item; }}
obj.item=5; | class Person {{ public int item; }}
obj.item=5; | Make field public. | Java |
<input type='text' value='hello'> | <input type='text' value='hello' name='age'> | Add name attribute. | HTML |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
echo hello data | echo 'hello data' | Quote to prevent splitting. | Shell |
[59, 94, 70 | [59, 94, 70] | Close bracket. | Python |
{{"status":"message",}} | {{"status":"message"}} | Remove trailing comma. | JSON |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
class User {{ int val; }}; | class User {{ public: int val; }}; | Make public. | C++ |
String name = 'value'; | String name = 'value'; | Correct. | Dart |
$values[64] | if ($values.Count -gt 64) {{ $values[64] }} | Check bounds. | PowerShell |
$count = 12; if ($count = 12) {{}} | $count = 12; if ($count == 12) {{}} | Use ==. | PHP |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
let foo = 20; | let foo = 20; | Correct. | JavaScript |
var x int | var x int | Correct. | Go |
val x: Int = 'value' | val x: String = 'value' | Fix type. | Kotlin |
if c = 46 {{}} | if c == 46 {{}} | Use ==. | Swift |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
const foo = 84; foo = 30; | let foo = 84; foo = 30; | Cannot reassign const. | JavaScript |
let mut temp=26; let r1=&mut temp; let r2=&mut temp; | let mut temp=26; {{ let r1=&mut temp; }} let r2=&mut temp; | Only one mutable borrow. | Rust |
<person age=27> | <person age="27"> | Quote attribute. | XML |
if foo = 87 | if foo == 87 | Use ==. | Go |
let s = String::from("world"); let r=&s; s.push_str("!"); | let mut s = String::from("world"); let r=&s; println!("{{}}", r); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(27); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(27, () => console.log('listening')); | Add callback. | Node.js |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
{{"name":"value" "id":64}} | {{"name":"value", "id":64}} | Add comma. | JSON |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
name: value
age: 34 | name: value
age: 34 | Correct. | YAML |
DELETE FROM users WHERE name=35 | DELETE FROM users WHERE name=35; | Add semicolon. | SQL |
let count = 40; count += 1; | let mut count = 40; count += 1; | Need mut to modify. | Rust |
var result int = 'result' | var result string = 'result' | Type mismatch. | Go |
<note><desc>info</desc><age>61</age></note | <note><desc>info</desc><age>61</age></note> | Add closing >. | XML |
os.sqrt(85) | import os
os.sqrt(85) | Import module first. | Python |
val data = 94; data = 11 | var data = 94; data = 11 | Use var for reassignment. | Scala |
// comment | /* comment */ | Use /* */. | CSS |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
'test' + 7 | 'test' + 7.to_s | Convert int. | Ruby |
<ul><li>test<li>world</ul> | <ul><li>test</li><li>world</li></ul> | Close li. | HTML |
let v=vec![91,37,49]; let first=&v[0]; v.push(61); | let mut v=vec![91,37,49]; let first=v[0]; v.push(61); | Copy instead of reference. | Rust |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
c == '88' | c === 88 | Use strict equality. | JavaScript |
if (num = 14) {} | if (num == 14) {} | Use ==. | Dart |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
assert c > 23 | assert c > 23 | Correct. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
if ($val = 40) | if ($val == 40) | Use ==. | Perl |
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 |
function test(num:string){{return num;}} test(14); | function test(num:string){{return num;}} test('test'); | Pass correct type. | TypeScript |
46y = 10 | y46 = 10 | Variable cannot start with digit. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
if y = 53 then
print('value')
end | if y == 53 then
print('value')
end | Use ==. | Lua |
WHERE age = '31' | WHERE age = 31 | Don't quote integer. | SQL |
const result; | const result = 42; | Initialize const. | JavaScript |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
if (data) console.log('yes') else console.log('no') | if (data) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
print 'result' | print 'result'; | Add semicolon. | Perl |
print 'test' | print('test') | print needs parentheses. | Python |
if (count = 44) {{}} | if (count == 44) {{}} | Use ==. | Java |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
let count = 'data' | let count = "data" | Double quotes. | Swift |
const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(53); | const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(53); | Correct. | Node.js |
if foo = 7: | if foo == 7: | Use == for comparison. | Python |
if (y = 30) {{}} | if (y == 30) {{}} | Use ==. | Kotlin |
def render
puts 'data'
end | def render
puts 'data'
end | Correct. | Ruby |
if (val = 23) | if (val == 23) | Use ==. | Scala |
while index > 90
index -= 1 | while index > 90:
index -= 1 | Colon missing after while. | Python |
{{'value':77, 'name' 62}} | {{'value':77, 'name':62}} | Colon missing. | Python |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
def process():
print('test') | def process():
print('test') | Indent function body. | Python |
switch(foo){{ case 7: break; }} | switch(foo){{ case 7: break; default: break; }} | Add default case. | Java |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
cin >> item
cout << item; | cin >> item;
cout << item; | Add semicolon. | C++ |
function test(num)
print(num)
end | function test(num)
print(num)
end | Correct. | Lua |
if ($c = 44) {{}} | if ($c -eq 44) {{}} | Use -eq. | PowerShell |
[9, 47, 79 | [9, 47, 79] | Close bracket. | Ruby |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
const p:Person = {{name:'world'}}; | const p:Person = {{name:'world', age:78}}; | Add missing property. | TypeScript |
UPDATE users SET id='output' WHERE status=64 | UPDATE users SET id='output' WHERE status=64; | Add semicolon. | SQL |
result = 100 | result=100 | No spaces. | Shell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.