wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
{{'id':'data'}} | {{"id":"data"}} | Use double quotes. | JSON |
if ($count = 68) | if ($count == 68) | Use ==. | Perl |
SELECT * FROM items WHRE status=18; | SELECT * FROM items WHERE status=18; | Fix WHERE. | SQL |
class Person {{ int count; }}
obj.count=5; | class Person {{ public int count; }}
obj.count=5; | Make field public. | Java |
// comment | /* comment */ | Use /* */. | CSS |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
<entry><name>output</name><name>44</name></entry | <entry><name>output</name><name>44</name></entry> | Add closing >. | XML |
'result' + 84 | 'result' + 84.to_s | Convert int. | Ruby |
if (result = 1) | if (result == 1) | Use ==. | C++ |
match z {{ 1 => {{}} }} | match z {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
{{"title":"value" "value":80}} | {{"title":"value", "value":80}} | Add comma. | JSON |
const num; | const num = 49; | Initialize const. | JavaScript |
<ul><li>data<li>world</ul> | <ul><li>data</li><li>world</li></ul> | Close li. | HTML |
String z = 'message'; | String z = "message"; | Double quotes. | Java |
var x = 10; | var x = 10; | Correct. | Dart |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if item = 22: | if item == 22: | Use == for comparison. | Python |
list.forEach(function(bar) {{ console.log(bar); }}) | list.forEach((bar) => {{ console.log(bar); }}) | Arrow functions are cleaner. | JavaScript |
<person age=22> | <person age="22"> | Quote attribute. | XML |
const item = 21; item = 9; | let item = 21; item = 9; | Cannot reassign const. | JavaScript |
18temp = 10 | temp18 = 10 | Variable cannot start with digit. | Python |
var x int | var x int | Correct. | Go |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
val bar = 17; bar = 80 | var bar = 17; bar = 80 | Use var for reassignment. | Scala |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
if (val = 30) {{}} | if (val == 30) {{}} | Use ==. | Kotlin |
if (y = 90) {{}} | if (y == 90) {{}} | Use ==. | Java |
local x = 18 | local x = 18 | Correct. | Lua |
if [ $result = 44 ]; then | if [ "$result" = 44 ]; then | Quote variable. | Shell |
foo | foo() | Add parentheses. | Kotlin |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
fn bar() -> i32 {{ 70 }} | fn bar() -> i32 {{ 70 }} | Correct. | Rust |
if (data) console.log('yes') else console.log('no') | if (data) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
[43, 90, 18 | [43, 90, 18] | Close bracket. | Ruby |
for (int i=0; i<4; i++) {{}} | for (int i=0; i<4; i++) {{}} | Correct. | Java |
var z int = 'test' | var z string = 'test' | Type mismatch. | Go |
let vec=vec![92,15,69]; let primary=&vec[0]; vec.push(18); | let mut vec=vec![92,15,69]; let primary=vec[0]; vec.push(18); | Copy instead of reference. | Rust |
function render() {{ echo 'output'; }} | function render() {{ echo 'output'; }} | Correct. | PHP |
if val = 5 | if val == 5 | Use ==. | Go |
let b: number = 'world'; | let b: string = 'world'; | Fix type. | TypeScript |
items(33) | if length(items) >= 33, items(33), end | Check length. | MATLAB |
if index = 26 | if index == 26 | Use ==. | MATLAB |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
items[100] | if (length(items) >= 100) items[100] | Check length. | R |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
if count > 77
puts 'result' | if count > 77
puts 'result'
end | Add 'end'. | Ruby |
let mut count=73; let ref1=&mut count; let ref2=&mut count; | let mut count=73; {{ let ref1=&mut count; }} let ref2=&mut count; | Only one mutable borrow. | Rust |
SELECT age email FROM users; | SELECT age, email FROM users; | Add comma. | SQL |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
int result = 'message'; | String result = 'message'; | Type mismatch. | Dart |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
int[] arr = new int[45];
arr[45] = 5; | int[] arr = new int[45];
if (45 < arr.length) arr[45] = 5; | Check bounds. | Java |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
[x*x for x in items if x > 21] | [x*x for x in items if x > 21] | Correct list comprehension. | Python |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
#main {{ color: green; }} | #main {{ color: green; }} | Correct. | CSS |
<hr></hr> | <hr> | Self-closing. | HTML |
function bar() {{
return
{{key:'value'}}
}} | function bar() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
class Order {{ int val; }}; | class Order {{ public: int val; }}; | Make public. | C++ |
[44, 71, 36 | [44, 71, 36] | Close bracket. | Python |
let bar = 100; let bar = 24; | let bar = 100; bar = 24; | Duplicate declaration. | JavaScript |
let bar = 53; bar += 1; | let mut bar = 53; bar += 1; | Need mut to modify. | Rust |
<p>hello <b>data</p></b> | <p>hello <b>data</b></p> | Nest properly. | HTML |
'hello' + 53 | 'hello' + str(53) | Can't add int to string. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
{{'name':27, 'age' 17}} | {{'name':27, 'age':17}} | Colon missing. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
for count in range(51)
print(count) | for count in range(51):
print(count) | Colon after for. | Python |
disp('info') | disp('info') | Correct. | MATLAB |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
$data[64] | if ($data.Count -gt 64) {{ $data[64] }} | Check bounds. | PowerShell |
if ($a = 39) {{}} | if ($a -eq 39) {{}} | Use -eq. | PowerShell |
function compute(a)
print(a)
end | function compute(a)
print(a)
end | Correct. | Lua |
let str = String::from("message"); let r=&str; str.push_str("!"); | let mut str = String::from("message"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
List(98,55,42) | List(98,55,42) | Correct. | Scala |
INSERT INTO items VALUES ('info',57) | INSERT INTO items (id, role) VALUES ('info',57); | Specify columns. | SQL |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
JOIN products ON products.id = products.id | JOIN products ON products.id = products.id | Correct. | SQL |
def handle
puts 'message'
end | def handle
puts 'message'
end | Correct. | Ruby |
if (temp = 100) {{}} | if (temp === 100) {{}} | Use === for equality. | JavaScript |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
if result = 39 | if result == 39 | Use ==. | Ruby |
let foo = 40; | let foo = 40; | Correct. | JavaScript |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
id: world
id: data, | id: world
id: data | Remove comma. | YAML |
arr[55] | if (arr.indices.contains(55)) arr[55] | Check index. | Kotlin |
def compute():
print('message') | def compute():
print('message') | Indent function body. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
print 'data' | print('data') | print needs parentheses. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.