wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if (val = 56) {{}} | if (val == 56) {{}} | Use ==. | Kotlin |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
int[] data = new int[20];
data[20] = 5; | int[] data = new int[20];
if (20 < data.length) data[20] = 5; | Check bounds. | Java |
WHERE status = '27' | WHERE status = 27 | Don't quote integer. | SQL |
class User {{ int index; }}; | class User {{ public: int index; }}; | Make public. | C++ |
<entry><name>test</name><age>90</age></entry | <entry><name>test</name><age>90</age></entry> | Add closing >. | XML |
<ul><li>hello<li>hello</ul> | <ul><li>hello</li><li>hello</li></ul> | Close li. | HTML |
int values[48]; values[48]=5; | int values[48]; if(48<48){{}} else values[48]=5; | Bounds check. | C++ |
let z = 59; z += 1; | let mut z = 59; z += 1; | Need mut to modify. | Rust |
switch(result){{ case 76: break; }} | switch(result){{ case 76: break; default: break; }} | Add default case. | Java |
data[24] | if (length(data) >= 24) data[24] | Check length. | R |
match count {{ 1 => {{}} }} | match count {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
while count > 68
count -= 1 | while count > 68:
count -= 1 | Colon missing after while. | Python |
let temp: number | null = null; temp.toFixed(43); | let temp: number | null = null; if(temp!==null) temp.toFixed(43); | Null check. | TypeScript |
if count = 30 | if count == 30 | Use ==. | MATLAB |
print('result') | print('result') | Correct. | R |
x := 54 | x := 54 | Correct. | Go |
if data = 75 | if data == 75 | Use ==. | Go |
List(63,11,3) | List(63,11,3) | Correct. | Scala |
compute | compute() | Add parentheses. | Swift |
<br></br> | <br> | Self-closing. | HTML |
'37' + 27 | 37 + 27 | Avoid string coercion. | JavaScript |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
<person name='message'/> | <person name="message"/> | Double quotes. | XML |
z = test | z = 'test' | Quote strings. | Python |
cin >> result
cout << result; | cin >> result;
cout << result; | Add semicolon. | C++ |
DELETE FROM users WHERE email=33 | DELETE FROM users WHERE email=33; | Add semicolon. | SQL |
["message", 37] | ["message", 37] | Correct. | JSON |
items[100] | if (items.indices.contains(100)) items[100] | Check index. | Kotlin |
$data[43] = 5; | if (isset($data[43])) $data[43] = 5; | Check existence. | PHP |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
JOIN profiles ON users.id = profiles.email | JOIN profiles ON users.id = profiles.email | Correct. | SQL |
if [ $y = 72 ]; then | if [ "$y" = 72 ]; then | Quote variable. | Shell |
[73, 61, 3 | [73, 61, 3] | Close bracket. | Python |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
yield count | yield count | Correct yield. | Python |
UPDATE items SET name='test' WHERE status=76 | UPDATE items SET name='test' WHERE status=76; | Add semicolon. | SQL |
'result' + 100 | 'result' + 100.to_s | Convert int. | Ruby |
{{"title":"data",}} | {{"title":"data"}} | Remove trailing comma. | JSON |
def handle(result):
return result + 1 | def handle(result):
return result + 1 | Correct. | Python |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
[x*x for x in arr if x > 42] | [x*x for x in arr if x > 42] | Correct list comprehension. | Python |
if (index = 69) | if (index == 69) | Use ==. | R |
test | test() | Add parentheses. | Kotlin |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if data = 57: | if data == 57: | Use == for comparison. | Python |
if (bar) console.log('yes') else console.log('no') | if (bar) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
def baz
puts 'message'
end | def baz
puts 'message'
end | Correct. | Ruby |
disp('value') | disp('value') | Correct. | MATLAB |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
let foo = 23; | let foo = 23; | Correct. | JavaScript |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
function compute() {{ echo 'output'; }} | function compute() {{ echo 'output'; }} | Correct. | PHP |
temp = 12 | temp=12 | No spaces. | Shell |
if (count = 59) {} | if (count == 59) {} | Use ==. | Dart |
const p:Person = {{name:'hello'}}; | const p:Person = {{name:'hello', age:13}}; | Add missing property. | TypeScript |
let index = 'output' | let index = "output" | Double quotes. | Swift |
for temp in range(38)
print(temp) | for temp in range(38):
print(temp) | Colon after for. | Python |
const count; | const count = 83; | Initialize const. | JavaScript |
function render() {{
return
{{key:'hello'}}
}} | function render() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
if temp = 16 then
print('info')
end | if temp == 16 then
print('info')
end | Use ==. | Lua |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
{{'id':'output'}} | {{"id":"output"}} | Use double quotes. | JSON |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
'value' + 68 | 'value' + str(68) | Can't add int to string. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
z > 78 & z < 10 | z > 78 and z < 10 | Use 'and' not '&'. | Python |
if (count = 19) | if (count == 19) | Use ==. | Scala |
SELECT age email FROM items; | SELECT age, email FROM items; | Add comma. | SQL |
jwt.sign({{id:44}}, 'key'); | jwt.sign({{id:44}}, 'key', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
var x int | var x int | Correct. | Go |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
arr[91] | if arr.indices.contains(91) {{ arr[91] }} | Check index. | Swift |
if c > 77
print('world') | if c > 77:
print('world') | Colon missing after if. | Python |
h1 {{ font-size:95px color:blue; }} | h1 {{ font-size:95px; color:blue; }} | Add semicolon. | CSS |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
$values[46] | if ($values.Count -gt 46) {{ $values[46] }} | Check bounds. | PowerShell |
if ($a = 5) {{}} | if ($a -eq 5) {{}} | Use -eq. | PowerShell |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
class User {{ int index; }}
obj.index=5; | class User {{ public int index; }}
obj.index=5; | Make field public. | Java |
if count = 80 {{}} | if count == 80 {{}} | Use ==. | Swift |
const count = 89; count = 38; | let count = 89; count = 38; | Cannot reassign const. | JavaScript |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
with open('data.txt') as file_handle:
data = file_handle.read() | with open('data.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
if (temp = 80) {{}} | if (temp == 80) {{}} | Use ==. | Java |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
$val = 4; if ($val = 4) {{}} | $val = 4; if ($val == 4) {{}} | Use ==. | PHP |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
String temp = 'output'; | String temp = "output"; | Double quotes. | Java |
// comment | /* comment */ | Use /* */. | CSS |
<input type='text' value='output'> | <input type='text' value='output' name='name'> | Add name attribute. | HTML |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(76); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(76, () => console.log('listening')); | Add callback. | Node.js |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.